Optimizing AI movement in multiplayer

Hello,

Im having a problem with AI movement in multiplayer.
I have situations in game when there are multiple moving AI characters near the player - up to 30.
Unfortunately their movement is very jittery on client side.
Each AI is using character movement component, and I guess this is the most costly thing on them when it comes to replication.

I’d like to know if there are any tricks to optimize character movement, and AI in general for multiplayer,
or if character movement component is unusable on AI in such numbers, and in that case what would be the best alternatives.

its not because of the AI its because you are replicating lots of data so its jittery.
and there is not an easy solution for that, behind it is too complex. you have many options:

  • spend several years to write your own movement system or maybe a deterministic engine :slight_smile: TOO HARD

  • predict the movement on clients, maybe a deterministic pathfinding so that instead of replicating location you replicate the destination and all client follow the same path, HARD.

  • decrease the movement speed as low as a disabled zombie so you don’t see any jitter cause they barely move

but a easy affordable solution that I tried myself is:

disable the replication of AActor.ReplicatedMovement. by default it sends lots of data that u don’t need.
write your own struct to send the required data as compact as possible. instead of replicating a FVector send the compressed location based on the size of your map, only send yaw rotation, etc …

then in the OnRep_ of your own movement struct. reconstruct the AActor.ReplicatedMovement and call OnRep_ReplicatedMovement.

hope it helps :slight_smile:

Hey Greg,

30 AI agents is not that much and it should just work, which makes me think you’re doing something non-orthodox, like client-side nav path following. Would you mind describing your AI setup?

Cheers,

–mieszko