Download

UFloatingPawnMovement versus AddActorLocalOffset/AddActorLocalRotation

I’ve been digging into UFloatingPawnMovement and experimenting with replacing my current spaceship code that moves the APawns around using AddActorLocalOffset and AddActorLocalRotation.

The things that motivated me to add a movement component:

  1. Separate all movement related handling to its own component.
  2. Make it easier to achieve multiplayer replicata (similar to UCharacterMovementComponent)

However, it seems to me that the only movement input function is


APawn::AddMovementInput(FVector WorldDirection, float ScaleValue = 1.0f, bool bForce = false)

I could just as easily implement that for the APawn or just use


AActor::AddActorLocalOffset(FVector DeltaLocation, bool bSweep)

Also, it looks like I will still need to rotate the mesh (e.g roll, pitch, etc.) to turn my spaceships using AddActorLocalRotation, since I can’t see any way to turn the mesh using the component.

Am I missing something, or is the above correct, and will UFloatingPawnMovement make movement replication of pawns any easier, i.e. can I simply set the component to Replicated and that is all or do I need to implement server/client handling for velocity, position, rotation, etc.?

Thanks.

Hey Tarostar,

I’ve been at the same point with the exact same motivation. I’m running into several replication problems now though (I have my own component derived from UFloatingPawnMovementComponent), as the server and client tend to differ a lot regarding the movement :frowning: (I wish we had the UCharacterMovementComponent here :confused: (at least it sounds like it works nicely))
At the moment, I’m only using the method you mentioned… It works “fine”, but as I said, the server and client differ quite a lot :frowning: (But maybe that is my fault somehow?)

I tried the Replicate Movement thingy in the pawn’s defaults, but that does nothing somehow. I don’t remember exactly if you could just tick bReplicates and it works (to some degree at least)… Right now I replicate my own Location of the Pawn on the server (with a seperate FVector-Property) and override the client’s pawn location whenever it receives an update from the server, however that is more like a workaround (that I really don’t like) than a real solution.

I’m new to networking so I did probably make some mistakes and/or explained something the wrong way, so don’t take what I wrote as 100% true.
I would love to hear your experiences with Movement-replication!