This seems to be a recurring topic/request among those starting to build VR experiences with UE4, so I thought it would be useful to make a short step-by-step tutorial covering it.
The tutorial includes two: 1. Direction of locomotion following the HMD orientation, 2. Direction of locomotion independent from the HMD orientation.
Both variations have a rotation option (left thumbstick) and the movement is constrained to an horizontal plane so there is no risk to go through the floor or fly off. There is also a collision capsule added to the pawn to prevent it going through walls and other objects.
NOTE: To keep it simple, this implementation is for a seated/in-place experience. Rotations will be inaccurate if you use it for a room-scale experience and start moving around IRL. This can be fixed implementing a roto-translation of the VR origin so the camera parented to it pivots around its vertical axis as expected. I may cover this in a future tutorial if anyone is interested.
i’m using this implementation a bit differently but i was wondering how one would go about changing the walk speed based on this tutorial you have presented.
EDIT: Problem solved…scale vector by int “Movement Speed”
Good you solved it yourself. Actually it would be better to use a float for that purpose.
And if you want to make the entity of the movement independent from the frame rate, you also need to multiply by World Delta Seconds. You can use Get World Delta Seconds for that:
I followed another ArchViz tutorial you made similar like this one. My question is how I can get the thumbstick control following HMD? Seems like it worked in your tutorial. But I watched and did 5 times exactly following your tutorial, the thumbstick control could not follow HMD, when pushing forward, it moves sideways.
@shineoooo If you take the Forward Vector and the Right Vector of the Camera (HMD) instead that the one from the Character, that should move the character in the direction you are looking with your HMD. I am showing this setup in the first tutorial but not in the ArchViz one. Anyway that part works exactly in the same way.
Thanks so much Marco! Not sure why I could not upload the image I wanted to show you. Anyway, I replaced them with Forward Vector and Right Vector. Everything works fine now but, only one issue, the camera height seems not correct. It is way higher than the VR teleportation one. I put two 1 meter boxes there as reference, it was like 2 meters high. I tried to switch to Eye level, then it turned out too low. Any suggestions?
@shineoooo I had someone else having a similar problem and it turned out they hadn’t setup the VR Character correctly. It is easy to overlook in the tutorial, but the VR Camera is parented to the VR Origin and the VR Origin is dragged to the bottom of the capsule. The VR Camera is in Location 0,0,0 relative to the VR Origin. If you drag the VR Camera, instead of the VR Origin, to the bottom of the capsule, you end up being much taller than expected. This is probably your issue so you want to double check that.
Don’t switch to eye level. That won’t solve the issue. Floor level is the right choice for ArchViz.
Thank you so much Marco! Problem solved. I think I moved VR Camera pivot mistakenly to the bottom of capsule instead of VR Origin pivot. Everything works now. Really appreciate for your help and thank you so much for your patience with newbie! You made my day!
Then you simply have only two values into the multiplication node, SpeedOfMovement and GetWorldDeltaSeconds. The rest is the same. The Facebutton input is triggered only when the button is pressed and that would be like having an Axis input with value 1.0
One idea could be to add a boolean variable which controls whether you are using teleportation or thumbstick locomotion. You can toggle it with one of the facebuttons. Depending on its state, you can enable the teleportation part of the code or the thumbstick part of the code. With that you would limit the interaction between the two modes.
Last Problem is that the capsule does not move with the camera if you make The Capsule Visible in Game you see if you make real steps the capsule dont move.
You mean if you move in real life in a room scale setup? Then no, the capsule will not move because it is the root component and the Camera is lower in the hierarchy and locked to the HMD. If you want this to work with room-scale movements you should look into plugins like Mordentral’s one. Or take a completely different approach where your collision checking volume is handled separately from the camera and kept aligned with it at each Tick.