- Start 3rd person character BP project in 4.22.3
- In ThirdPersonCharacter bp, add a Set Actor Rotation on left click, set it to the controller’s rotation: https://i.imgur.com/tNUo6Nq.png
- Play. You will see the character rotates in the direction the camera is facing on left click. Works great.
- Tick “Run Dedicated Server”
- Play. You will see that many times the character will not rotate on left click.
I understand this scenario is not properly replicated and no other player will see the character rotating which is fine. But why is this rotation sometimes not working?
- The return value from Set Actor Rotation is always true, even when it doesn’t work.
- If I print out the rotation before Set Actor Rotation and after the Set Actor Rotation … it’s hard to explain this. So the after ALWAYS shows the rotation it should have changed to. The before ONLY shows this rotation if you see that the actor has rotated. So as an example…
(Controller rotated to yaw 110)
- Click 1 (didn’t work). Before: 0,0,0. After: 0,110,0. Character hasn’t rotated.
- Click 2 (didn’t work). Before: 0,0,0. After: 0,110,0. Character hasn’t rotated.
- Click 3 (worked). Before: 0,0,0. After: 0,110,0. Character rotated.
(Controller rotated to yaw 200)
- Click 4 (didn’t work). Before: 0,110,0. After: 0,200,0. Character hasn’t rotated.
So… always after the Set Actor Rotation, “Get Actor Rotation” will return the correct rotation even though the character has not rotated visually. I did a weird test: https://i.imgur.com/PLeUYrZ.png . After the “Set Actor Rotation”, the first “Get Actor Rotation” shows where it should have rotated to. Then, after that .1 second delay, it starts printing the old rotation.
So somewhere in that .1 seconds, the character’s rotation is being (sometimes) undone.
Edit: I did another test, rotating a simple static mesh actor instead of the character and this worked every time. So there must be something about the character that’s causing this sporadic behavior. Continuing to test.
Edit2: Instead of using Set Actor Rotation on self, I specified the mesh on the character. Doing this seemed to work every time… but I’m not sure it’s what I really want to be doing. I tried specifying the capsule component specifically and got the same inconsistent results as before with both Set World Rotation and Add World Rotation.
Edit3: Ah-HA! If I disable the movement component, the rotation works perfectly (using Set Actor Rotation). So there’s something in the movement component that’s preventing this from working right. It seems like disabling the movement component temporarily is a bad way to go about fixing this so I’m looking for other solutions. Maybe I can perform the rotation using the movement component instead.