Game Development Community

AIPlayer speed/animation sync

by Stefan Lundmark · in Torque Game Engine · 02/08/2006 (11:32 pm) · 7 replies

AIPlayer run-animation does not sync with speed like the normal Player does.
Makes the animation VERY jerky and it looks very bad.

Quote:Steps to reproduce:

1. Go into player.cs and into the PlayerBody datablock.
2. Change maxForwardSpeed, maxBackwardSpeed, maxSideSpeed to 1.
3. Run TGE and watch Kork "jerk around" his path.

Any chances this bug will get fixed? If not, could anyone point me into the right direction to look so I could fix it myself and post the result here?

#1
02/09/2006 (3:26 am)
What you're describing isn't a bug, by default Kork gets his values from the same datablock as the standard player, that being the datablock PlayerData(PlayerBody) section inside player.cs.

If you want your ai player to have independent values from the player just create a new datablock for it.
#2
02/09/2006 (5:12 am)
After re-reading your post, I'm pretty sure that you misunderstood the whole problem, because your post has nothing to do with the issue :/

This is not about Kork and the Player having the same runspeed. Of course they have the same runspeed, they share the same datablock.. which is the whole point.

This is about the animation of Kork's run sequence, and that it's not synced with his runspeed, while the player (who's sharing the same datablock as Kork) *has* synced animations.
#3
02/09/2006 (10:29 am)
I've not found a fix yet, but I thought I'd add that the sync problem starts to appear below 2 in speed and only on AIPlayers. The latter complicates finding a fix alot :/
#4
02/09/2006 (11:41 am)
I have been hitting my head against the wall for months around this bug. I've done 3 TGE games already, and in none of them I managed to fix that.

It also happens when you have a very low framerate, or when the network updates start to lag due to many bots on the screen at the same time. This is not a difference between Player and AiPlayer, but a difference between client-controlled players and AI-controlled players. The true player updates it's animation fine, while all bots stutters. If the framerate is low enough, or the network is hammered enough, the bots will go as far as not player the run animation at all.

Let me tell you what I have discovered so far. I believe it is a problem regarding the ghost updates of non-client controlled AiPlayers. When the updates become too far apart (low fps, lag), the bot velocity gets zero'ed before it can recieve it's updated value from the server. It still move properly, probably due to the interpolation data still being valid, but Player::pickActionAnimation() will choose the root animation when the velocity is zero. When the mVelocity value gets updated, the bot will go back to the run animation, starting it again. That causes the stuttering.

The problem is that I could never quite figure out why the velocity was getting zero'ed on the ghost between server updates.
#5
02/09/2006 (11:50 am)
Thanks for the info Manoel. I've been digging in the wrong place, then.

I still don't understand why this doesn't affect client-controlled players.

Ben, you watching this? Any guesses?
#6
02/13/2006 (2:26 am)
Can anyone from GG comment?
#7
02/13/2006 (6:37 pm)
www.garagegames.com/docs/tge/engine/classPlayer.php#a38

Control objects (i.e. those controlled by a client) get updated via writePacketData/readPacketData instead of packUpdate/unpackUpdate. writePacketData/readPacketData writes the Player's data at a higher precision than packUpdate/unpackUpdate which can make for a smoother experience. The control objects are also scoped at a higher priority than the non-control objects so tend to get more network updates. AIPlayers tend to be very sensitive to your network bandwidth. Increasing your $pref::Net::PacketSize can help a lot (it maxes out at 450 without changing the source code). Also, using the Advanced Camera resource can eat a lot of network bandwidth and adversely effect your AIPlayers.