Download

Help! How do I decouple hands from HMD rotation in Epic's FPS template?

I’m using the FPS Template in VR to find my feet with development with my Oculus headset and Touch controllers. However, I have stumbled into an issue immediately. The VR hands and gun provided with the FPS template have their relative position and rotation locked to the HMD so that if I turn my head, the guns will move & rotate with them. They still have offsets that take into account hand movement, which is similar to how PSVR titles track Dual Shock 4 movement, but it’s not suitable for Touch. Vive & Move development.

Does anyone have any idea how to unlock the hands from the head? Do I need to create a new BP, separate from the player pawn, just for the hands?

Also, at the moment I’m manually hiding the standard gun & arms and making the VR hands visible because the initial ‘Is Head Mounted DIsplay Enabled’ check doesn’t seem to register that UE4 is running fine on my Oculus. Is this expected? Or is there a project setting I’m missing somewhere to force this on?

If you want to enable the use of Motion Controllers in the FPS Template, all you have to do is to manually set the Use Motion Controllers? boolean variable inside the First Person Character blueprint to True. That will cause the body attached arms + weapon to be replaced by the standalone weapon attached to the Right motion controller.

I can already do that. The problem is that with the FPS Template, if you turn your head, your motion controller world positions and rotations are moved and rotated too. They’re using local offsets relative to the camera.

I suspect the solution is to take the controllers out of the player pawn’s, create hand controller BPs and spawn them on play, which is how the Motion Controller template currently does it.

Apologies but I don’t follow your reasoning.

In the standard FPS template the Motion Controller components are not parented to the FirstPersonCamera, they are at the same level. Both are parented to the root component, which is the collision capsule.

What is parented to the FirstPersonCamera and therefore moves with it is Mesh2P, but that one is hidden when Using Motion Controllers? is set to True. Also, when Using Motion Controllers? is set to True, the VR_Gun, parented to the right motion controller, is displayed.

Are we looking at the same template or not?

First things first, screw the FPS template for VR. You’re going to spend a lot of time reinventing the wheel. I’d HIGHLY recommend starting with Mordentral’s VR Expansion Plugin example instead. It has everything you could possibly want and more out of the box.

Official thread: VR Expansion Plugin - VR and AR Development - Unreal Engine Forums

I would say it depends on what the objective is. Mordentral’s plugin is great to quickly get you to production and does a lot of the heavy lifting for you. On the other hand, if one wants to learn the basics of how VR works in UE4, using a plugin (any plugin) may not be the best option for the exact same reasons.

The FPS template contains a very basic VR setup, but it is largely incomplete. The standard VR template is definitely a much better choice to get started.

Yeah I would argue that my plugin and template are actually pretty bad for complete beginners, they would likely be overwhelming.

However I’ll note that the plugin isn’t intended to “get into production” It simply does some things that straight up aren’t possible in blueprints only and some things that are fairly difficult even in c++.

@mordentral You are too humble! :wink:

I spent around 2 months (as a beginner) trying to hack VR hands and proper VR character movement into some combination of the FPS and VR templates, only to find that mordentral had done those things far better in the plugin. I learned 100x more from digging through the plugin code than I did during those 2 months of tinkering. I suppose it is a bit daunting, however.

Issues like this one however are pretty silly to worry about when they’ve already been solved. I remember having issue after issue like this starting out and really none of them ended up being things I needed to worry about. HMD facing the wrong way, height being wrong, hand motions being rotated, mouse affecting rotation, capsule positioning, jittering, collision issues, etc etc.

The basic VR template is definitely better than the FPS template though. So again, screw the FPS template. It uses a pawn instead of a character however. I’m assuming OP wants to use a character since they’re trying to use the FPS template, in which case the expansion plugin template will be much more useful.

Apologies, I misread the tree. However, that still doesn’t solve the actual issue at hand: How to decouple motion controller position and rotation from the HMD in the FPS template.

As SlimeQ says, the VR template also handles movement different from the FPS template. I was hoping to avoid Code Plugins and do everything in Blueprints, but may give the Plugin a shot next week.

Also, the FPS Template fires projectiles from your head when using Motion Controllers as well, naughty Epic!

I really struggle to match your experience with the FPS template to the one I am having. Not sure where the problem is, but in my case the controllers are not “coupled” to the HMD and there is no firing from the head. The firing happens from the weapon held in the right hand (right motion controller). Go figure!

Oh, i think I might know what’s going on. In fps template capsule rotation follows camera (I think) so if controllers are parented to it you’ll have weirdness. This is a shot in the dark.

You will soon find that your collision capsule is locked to the center of your play space and fixing that in blueprint will perform horribly. Probably not worth the effort.

The shooting from the head thing is pretty weird though, I suspect you may have broken something. Try starting with a fresh template and just changing the bUseMotionControls boolean

@Jimmy_Jazz I am currently experiencing the exact same problem when using the FPS template for VR. When moving the HMD the motion controllers also move. Did you or has anyone found a simple solution to for this within the FPS template? @SlimeQ I think you are correct with regards to the capsule.

The FPS template does not use the Motion Controller (right one) unless you edit the FirstPersonCharacter Blueprint and set the UsingMotionControllers? variable to True. If you don’t do so, the FPS template simply uses the gun mesh parented to the HMD, which may give the impression the Motion Controller move with the HMD when actually there is no motion controllers used at all.

Hey Marco, I have modified the FPS template so that it no longer has a gun, I have attached the oculus hands to the motion controller components that are within the FPS template to begin with? I have also parented the camera and both motion controllers to an Arrow, to reset the height of the VR camera in relation to the ground. I am able to use the HMD and motion controllers perfectly fine, plus I have also tried setting the boolean to true for the motion controllers. (Is that what you mean - image below) However, the problem still persists when rotating the turning your head, the motion controllers follow.

Here is the current BP and I have also included a little video test to help explain what I mean with regards to the hands - if you look at 26 seconds, even though im using the right thumbstick to rotate the camera, the same is happening when turning the head…i.e. the hands follow VR Data Room Fire Test - YouTube

@Speedy-P What I mentioned above was under the assumption you hadn’t modified too much the FPS template, but now I see you made quite some changes/merging of different templates. I am traveling at the moment without access to my dev system so I cannot double check that, but could you try parenting the Camera and the MC to a SceneComponent instead of an Arrow? You can keep the Arrow, just parent it to as well the SceneComponent if useful. Does it make any different respect to your issue?

Also in the attached Blueprint, the execution pin of the Branch node is not connected. Is that wanted?

I encountered this same issue. And here’s the easy fix:

Uncheck “Use Pawn Control Rotation” in the camera component!

The player is rotated along with the camera by default. If you leave that checked, the hands will rotated with the head because the whole character gets rotated with the head instead of just the camera.

Woooh! Fixed!