@sergey, i don't think he's doing any pathfinding here but general AI and setting animations per one of 3 actions.
@hell_666: try
loop object vs
play object (especially for the walk and sprint animations). as it stands now, you only play the animation
once and then have to
restart it even if the animation is the same as the last one.
this is going to require tracking of the
last animation played so if the AI
changes actions, the function will know to loop the next/new set of animation frames. if it's the same action as before, you don't need to do anything with the animation as it will continue to loop on its own.
also, you said "multiplayer". is this online?
and, how many AI entities are we talking about, here? you said "many" which could be dozens to hundreds+.
either way, you should consider updating AI for 1
group at a time (per loop) vs ALL AI entities EVERY loop.
ie, let's say you have 100 enemies running around... fact is, they really don't need to be checked on every single loop/iteration, if you're careful (without knowing more about your game, i can't really suggest anything to watch for but considerations should be made, regardless).
if, instead, you process AI 1-10 in one iteration, then 11-20 in the next loop, etc, until all 100 are looked at (10 loops total), you cut the "work load" by 90% each loop. then you just restart the checks on 1-10, and so on.
finally, what kinda of performance/frame rate do you get if NO animations are playing or being set vs the FPS you're getting with the way you're doing things now?
Virtual Nomad @ California, USA . DBPro V7.5
AMD Phenom™ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit