How Do I Replicate Rotation in VR?

I have a custom VR character with a character movement component, VRRoot Scene, and 2 motion controllers.

The character Mesh rotates based on the HMD camera. Rotation only works locally.

Everything replicates fine over the network but I can’t figure out how to replicate rotation. Even the server doesnt replicate rotation. I tried using an RPC to server to multicast the VRRoot & Mesh Transform but it didnt work.

Here’s how my blueprint is setup.

Here’s how I usually handle rotation, from my own VR template:

It looks more complex than it is :joy: First I take the raw hardware input and feed it first into a client RPC which then feeds into a server RPC, and executes the rotation code. The first few booleans are just checks to reduce unnecessary calculation, plus a check to see if the user has set to smooth rotate or snap rotate. The skinny of it is that rotation is applied to VROrigin via the rotation nodes. The VROrigin component (and everything else in the pawn that you want to send over the server) has ‘component replicates’ set to true in the details panel, as well as the actor itself.

Youll probably need to tweak exactly how to apply rotation, but this should replicate perfectly over the server.


Interesting, Thank you for such a detailed response of how you accomplished this. My setup is a bit different but since you mentioned setting the VROrigin to component replicates might be the trick I need.

I was basing the character off of my third person character which replicates perfectly except that one doesn’t have replicated components.

Since posting this question, I have edited my animBP to pivot the pelvis based on the HMD rotation. It’s untested over multiplayer yet but I think that might be my ticket to success.

I was able to replicate my motion controllers transform and the rotation of the HMD for the players head, applied the same concept for rotation but it didnt work at all. I’m gonna test what I’ve done in the AnimBP and then move towards replicating components and retrying an RPC solution.

Yeah I noticed that your hierarchy is different to mine in the project im currently working on, so you may get different results. For instance, it looks like youre using the inherited mesh component, which isn’t a child of VRRoot, so any change to the rotation of VRRoot wont be reflected in the mesh. You could try to rotate the actor itself or the capsule component, which should work if the actor is set to replicate. Also, replicating animations will require a bit more calculation. In my project, I use a replicated variable set to OnRep_Notify and set the grip pose of the VR hands that way so that the pose is replicated on the server. Which looks like this, at the moment:

The first variable is the blend space in the default hand AnimBP, just instead of setting it directly I use a replicated variable (in this case, HandGripStateR for the right hand) and set the GripState variable in the notify function, which works fine. Also, because it’s the same button as the default grip state, I can also set whichever pose I need via the PickupItems variable. This is all pretty project specific, just consider it a heads-up that animation blueprints dont magically replicate on their own :slight_smile:

1 Like

Alright. My setup was built based on the VR Cookbook and I’ve changed it a lot. All of this works perfectly in single player…

Here is how some of my AnimBP is setup.

Inside the VR Character. ReplicatedCharacterTransform is running on Tick after checking to see if it’s locally controlled. I think this works because the controllers do react properly over the network. Tried this method for rotation too and it didn’t work. (Not shown).

EDIT: The pelvis rotation didnt work as expected so I went back to interpolating the yaw rotation from the camera to the mesh inside of the VR Character on Tick.

Okay. After a long week of testing over 15 different solutions, I am coming back to say that nothing has worked in my favor, I am absolutely stuck on this problem.

After setting everything to “Component Replicates” I was able to see the Server move and rotate on the Client. Works great! So I moved onto replicating the controllers and the camera transform using the same method above. Also works great and smooth too!

But here is where my problem lies, no matter what I try, the clients rotation is not replicated to the server even though everything else works.

I tried:

  • Setting the World Rotation of the Mesh from Client to Server.
  • Interpolating the World Rotation of the Mesh from Client to Server.
  • Camera Rotation to Mesh World/Relative Rotation.
  • and any combinations of the above.

One of these solutions should have worked. But unfortunately it looks like the Server is locking the rotation and preventing the Clients rotation from being sent to the Server.

Here is one of the methods I tried, with and without the “Locally Controlled” node connected to false. Shouldn’t this work??

I think my rotation is being blocked by the server. Some people have suggested in past forums to use “Set Control Rotation” since I’m using the movement component but unfortunately all of the screenshots on those are not found and I don’t know how to set that up without repackaging a billion more times.

Can someone PLEASE help me figure this out? It’s been 2 weeks and countless hours of packaging over and over again.

Some news:

I have figured out how to replicate rotation but that required turning off “Replicate Movement”. But now my client can’t walk… Trying to RPC the clients movements but its not working so well either. Ugh!

I figured it out!

If I set the Camera to “Use Pawn Control Rotation” and then set “Use Desired Control Rotation” with “Use Controller Rotation Yaw” disabled, I get smooth rotation over the network! It also doesn’t affect the motion controllers since Controller Yaw is disabled. The -90 is my own preference based on my character.

But be warned, if you have a spawn point that isn’t 0, 0, 0, it will mess up rotation when you spawn. I reset the rotation to 0, 0, 0, when I spawn the player to fix this issue.