Im trying to set up a space based game in which a variety of “equipment” has reaching impact on how the players pawn moves.
To that end Ive set up a system that in general acts in the following manner:
Player Controller gets mouse click and sets the hit location to an OrderLocation variable in the Pawn.
OrderLocation is replicated using a server function:
Set**OrderLocation**(FVector Location)
{
if (Role < Authority) **OrderLocation** = Location;
ServerSet**OrderLocation**(Location);
}
OnRep_**OrderLocation**()
{
}
ServerSet**OrderLocation**(FVector Location)
{
**OrderLocation** = Location;
}
In Tick() a bunch of code is called to determine how to face, how fast and when to move towards the OrderLocation, and when and if the pawn should strafe side to side to avoid obstructions, ect…
This code outputs an FVector NewVelocity variable that is directly added to the pawns velocity via GetCharacterMovement()->Velocity = NewVelocity;
Every thing works fine in single player but when testing over a network for multiplayer, the Server’s version of the Client does not match the movement(or rather the lack thereof) of the Client when said Client comes to a stop.
Instead the Server Version of the Client acts as if it has not yet reached its OrderLocation, and continues to move and loop around to the OrderLocation even though it clearly knows where the OrderLocation is. It also jitters while doing this. The Server Version of the pawn moves fine as long as the Client Version is moving, it only starts jittering when the Client Version stops.
Any thoughts on what might be the problem/ or what I might need to do to fix this would be GREATLY appreciated.
All my previous work has made use of the default AddMovementInput() calls for Pawns, this is the first time trying to get custom movement through directly interacting with the CharacterMovement’s velocity.