NPC Motion Optimizing
After a test with 700-800 NPCs we figured out that root motion with animators doesn’t scale well with the amount of players even if inactive agents are deactivated. So I have to solve the motion in a different way. E.g. for a walk or run movement I will use just steering behaviors entirely, it looks nice and provide good performance. On the other hand I have to match the animations with the movement of the agents separately because the server just sets the position and orientation, but not which animation (or combination of multiple) is necessary to get there. In this case the clients have to trace back and calculate how the agent has moved since the last update and hand over the movement and rotation speed to the animator.
Unfortunately this doesn’t work well for animations with a unique or complex motion. In this case I use animation curves which I extract from specific animations as shown below. When an animation like ‚attacking‘ is triggered, the movement code gets the position and rotation values for each frame and overrides the movement of the steering bahviors.