making my characters head follow the rotation of the camera (Replicated)

I’ve been trying for a while now I cant get this to work, it works Really good but as soon as it comes to multiplayer it doesn’t rotate, I know I need to replicate it but I don’t know how, any advice would be extremely helpful

Hi @Kdog545457

For this, what I usually do is have a replicated Rotator variable and CalculateHeadRotation() function in my character’s Class/BP, which I can set how often it updates.

Then, I use that variable in the character’s Animation Blueprint. Since it’s replicated, everyone online will receive the update and rotate the head accordingly.

From your message I assume the head rotation works locally, so just apply Transform Bone in the ABP on the same bone you’re updating locally.

You can update the variable on tick if you want smooth as close to realtime as possible updates, but for Net optimization I’d do it with a Timer instead every 0.2s or 0.1s, then interpolate the rotation so the result is smooth.

The variable should be Replicated, not RepNotify unless you want to do something everytime it updates, but shouldn’t be the case.

Update the variable with a Server event, otherwise it won’t replicate unless the character you’re updating is running the server itself.

Player/Character BP

VARIABLE HeadRotation
image

FUNCTION CalcualteHeadRotation

FUNCTION ChangeHeadUpdateState
Use to toggle On/Off head rotation updates

EventGraph simple setup
image

Animation Blueprint

EVENT GRAPH

Create and update ABP HeadRotation from your Character class

ANIM GRAPH

Use Transform(Modify)Bone to change the character’s head rotation. Select the correct bone on the node’s details


Yes this does work but it rotates both of the clients heads from one controller, am I doing something wrong?

Can you share how you’re getting/calculating the head rotation you’re replicating?

Here

If that function is being called on the server as in my example, only the character in which that function is being used should update its head rotation variable.

If you do exactly as I showed it works 100%.
If you changed it to multicast, that would be the reason why all follow the same rotation.
If that’s not the case, maybe you have some left over code lingering trying to force head replication?

yes sorry it was the plugin I had installed, Works great now, thanks for all the help!

Awesome! Happy to help.

In that case mark it as solved so other people can find the solution :wink:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.