Download

Camera Component replicates rotation even though replicate disabled?

I’ve been struggling with this one the entire day now, hoping someone can give some clue.

So I have a character blueprint with a “character movement” component and a camera inside. Player is “facing away from the camera” originally (3D compatible controller), but I’m doing a 2D sidescroller (all working fine) but I just need to have the initial rotation set to +90 degrees (so you don’t see the “side” of a sprite when it’s spawned. Sound trivial (just rotate the Actor) but in a multiplayer setting it messes in some unexpected way with the camera rotation.

  • Replication is disabled for the camera - so it should not care about replicating position/rotation
  • First thing done is detaching the camera from the Actor ( a custom CameraMovement component will handle following the Actor) so again changing position/rotation of the Actor should be irrelevant to (the now) detached camera.

So when running it first hits the breakpoint in UCameraMovement::BeginPlay on the authority - which is fine. It does the detach and basically changes the position a bit (mainly distance from the Actor). Rotation is 0,0,0.

next we hit the following breakpoint in the blueprint - again through the “authority” path (so on the server) which then changes the Actor rotation Z/Yaw to 46 degrees (some recognizable number, actual value is irrelevant) - all fine so far.

Then we hit the UCameraMovement::BeginPlay on the not-authority (so client)… At this point, weirdly enough the relative rotation of the camera is 46 degrees… So how did that get changed?!

I can see the Actor is turned by 46 degrees (which is expected) - but the detached(!) camera which is not(!) replicated is now also rotated by 46 degrees (confirmed because it actually looks in a 46 degree rotated angle on my scene)… I don’t understand why?!

Any ideas? (Even if just how to catch it the exact moment when it happens?)

Ohla… I added some dummy code in the constructor (so I could break in the client-side constructor of UCameraMovement, get the camera, get the address of the Rotation.Yaw and use that to set a data breakpoint)… And that breakpoint was triggered by DetachFromComponent - which is using the “KeepWorld” rotation from the Actor which apparently was already replicated to be 46 degrees…

And indeed:

So basically I need to do the Detach earlier - or changing the Actor rotation later… (or completely move my Camera out of there into its own blueprint). Going to experiment a bit, see what’s possible.

or alternative #4… use KeepRelative instead of KeepWorld for the rotation detachrule / make it a property…