Does the position change need state synchronization? (23248)

In my multiplayer game, I need to synchronize the patrolling enemies’ positions in all clients. These position changes are written by script, not by players’ controls. I tried to make State Synchronization to their positions, and I found it was acting like they were jumping/poping from one point to another, like I was running in pretty low frame rate. (However the movement in local is quite normal.) No matter I used Unreliable or Reliable Delta Compressed, it was the same.

So I wonder, what would be the right way to handle such position change? Is it a wrong way to use State Synchronization in this case? Thank you very much.

2 Answers

2

you could state sync a variable and then have the enemy lerp to that variable.

Yeah, if the difference is small you should just guide him towards the correct position. If it is big, however, you may choose to actually teleport him or have some clever way of fixing it.

Make sure the enemies are only controled by the server. If your “AI” script is also enabled on the clients it will move on it’s own and the position gets frequently overwritten by the server updates.