Reducing Lag In NPC Animations (If A Better Way Exists)

,

Hello! I am currently working on a game with many NPC characters, and I was wondering how to make my game run faster on slower devices. I haven’t been able to test on a slower device (my PC is fairly fast) so I’m not sure if my method is actually helping. I will describe my current method of lag reduction below, and I would like feedback on how effective it is, as well as possible alternatives, such as playing the animations on clientside (and how I should do that).

My method:
A server script in each NPC plays the walk animations whenever their heads velocity’s magnitude is > 6. If the player’s camera is more than 250 studs away from the center of the map (all the NPCs are in the same general area), all the NPCs get placed in ReplicatedStorage, and do not get moved back until the camera is within 250 studs of the map’s center point.

Should I run animations on clientside? Should I have a setting in-game to toggle the animations? Or will that overlap with the 250-stud thing and cause issues? All feedback is welcome!

Once again, there it not exactly an issue with this, but I am just looking for better ways, if any exist.

Thank you!

1 Like

I don’t have time to write any major response, but the bottom line is that moving things to the client does 99% of the time make performance better. I’ve gone as far as having all NPC movement on the client. I had 1 player as the host (the one the npc is targeting) and replicated different states to the other players. Of course this kind of approach has quite strict requirements regarding security.

1 Like