Moving in VR

I’m a programmer and recently got my Vive and of course I can’t help but want to mess around and try to build a little something, but treat me like a noob who knows nothing. I’m working on a ski simulator…so think character starts at top of hill and travels down until they get to the bottom.

I just want to make sure I am taking the right approach when it comes to actually moving the first person camera. I’m not using physics, and in fact the pawn doesn’t even have a mesh besides the controllers at the moment. Just a camera. What i’m doing is setting a specific speed based on an action the user does with the controllers. Then i’m moving the actual coordinates of the entire pawn forward along the X and maintaining a ground position by setting the Z to the ground by using a line trace down from the headset camera. Sound right so far?

Now when it comes to turning left or right i’m thinking when I move both the controllers over to either side of my body i’ll adjust the Y the same way I do the X. This will determine the direction the pawn moves but will also allow the user to move their head however they want without affecting movement. I can’t figure out how to get the proper Y coordinate though. Should I somehow get the center point of both controllers, then use that Y coordinate? Should I somehow be using rotation instead of location? Basically I just want to be able to move both controller 45 to the right and move the pawn 45 to the right and the reverse for left.

One more side note, i’m setting the X, Z, and Y every “tick” and using the delta the maintain proper frame rate. I am also using blueprints for now so I don’t really know how to do anything with the C++.

I’d rotate the pawn based on the distance from the midpoint between the controllers to a line projected out from the pawn along its forward vector (FMath::PointDistToLine | Unreal Engine Documentation). You probably want to have a deadzone in the middle, so if the distance is less than some value it doesn’t rotate at all, so it’s not constantly wobbling.

Bear in mind though that if you rotate the pawn you can’t move forward by just increasing the X, you’ll need to add the pawn’s forward vector instead. Also you’ll want to add at least an arrow component so you can see which way its pointing!

Just realised you said blueprint only! I don’t know if there’s a BP node for PointDistToLine, but it’s just vector projection anyway - lots of examples on the web.

Ya I plan on stopping side movement completely when the controllers are more than x distance apart. So rotation is the way to go? I just thought location might be better since that is how I am moving forward. I’ll have to dig into your answer and see if I can figure it out…thank you!

I also do plan on adding geometry for the character…just not at that point yet.

Any idea how to go about getting the mid-point between the controllers?

I could see both working, but they’d look very different. Rotating is more natural, but sliding without rotation might be more… ‘gamey’. I’d say sliding would fit more in the sort of game where you ‘jump’ left or right to avoid obstacles, for instance.

If the positions of each controller are A and B:

B-A gets you the offset from A to B. Pretty obviously if you add that offset to A, you get B. If instead you add half that offset to A, you get halfway to B - the midpoint.

So the midpoint is A + ((B-A) * 0.5f).