Strange AI / Animation problem
by Chris Labombard · in Torque Game Engine · 08/22/2005 (11:09 am) · 11 replies
I am having a very strange problem with my bot animations.
The bots animate sometimes, and kinda skip along the rest of hte time. I searched around the site and found some things, but none of them seemed to fix the problem.
The strange thing is: If I set my player shape to be the bot, it animates perfectly. It is only when it is set to be a bot that it doesn't animate properly. So I know that the dts and cs are set up properly.
For reference: I am using a modified version of the AIGuard resource, and my bots use a very warped Orc rig... where the arms are actually attached to eyeballs, and I think the head nodes might be attached to it's mouth. I am currently JUST using the Orc anims. I have custom anims, but want to make sure everything works with a known configuration first.
Can anyone point me to what might be causing the problem ?
The bots animate sometimes, and kinda skip along the rest of hte time. I searched around the site and found some things, but none of them seemed to fix the problem.
The strange thing is: If I set my player shape to be the bot, it animates perfectly. It is only when it is set to be a bot that it doesn't animate properly. So I know that the dts and cs are set up properly.
For reference: I am using a modified version of the AIGuard resource, and my bots use a very warped Orc rig... where the arms are actually attached to eyeballs, and I think the head nodes might be attached to it's mouth. I am currently JUST using the Orc anims. I have custom anims, but want to make sure everything works with a known configuration first.
Can anyone point me to what might be causing the problem ?
About the author
I have been a professional game programmer for over 5 years now. I've worked on virtually every platform, dozens of games and released a few of my own games, including 2 iPhone titles and a title waiting release on Big Fish Games.
#2
I am not using an AIManager. I don't know much about it, but I thought it was only for AIPlayer class objects. I will look into it.
My bots don't have weapons, so it can't be that.
I don't think it is hte model, as the model animates perfectly if I set it as the player model.
08/23/2005 (4:13 am)
Brian - I haven't tried the normal Orc. I will try it today. I am not using an AIManager. I don't know much about it, but I thought it was only for AIPlayer class objects. I will look into it.
My bots don't have weapons, so it can't be that.
I don't think it is hte model, as the model animates perfectly if I set it as the player model.
#3
I have been wanting to confirm that myself so I went in and removed my aimanager script object and just spawned some bots on start, they all worked fine so it wasn't that, sorry for the confusion.
My problem was that the animation would work for me and the first aiplayer , but not other aiplayer.
08/24/2005 (12:15 pm)
My bots are aiplayer. Dont think i need an aimanager andI have been wanting to confirm that myself so I went in and removed my aimanager script object and just spawned some bots on start, they all worked fine so it wasn't that, sorry for the confusion.
My problem was that the animation would work for me and the first aiplayer , but not other aiplayer.
#4
It still does the same thing, which tells me it must be an issue with my scripts, or with the source files.
The source is stock AIGuard resource, so I doubt it is the source.
Using deductive reasoning, and seeing what they actually do, I am getting the idea that they skip when a certain action is performed. and I am thinking that that action is adjusting the move destination.
I don't know why. It is just a gut feeling.
Once they get close enough to you they just continuously skip.
08/27/2005 (6:38 am)
Ok.... I tossed in the stock Orc, and his animations. It still does the same thing, which tells me it must be an issue with my scripts, or with the source files.
The source is stock AIGuard resource, so I doubt it is the source.
Using deductive reasoning, and seeing what they actually do, I am getting the idea that they skip when a certain action is performed. and I am thinking that that action is adjusting the move destination.
I don't know why. It is just a gut feeling.
Once they get close enough to you they just continuously skip.
#5
08/28/2005 (8:47 am)
Are you slowing the velocity of the character down at all (e.g. to obtain a walk animation)? I've noticed that if you reduce the maxForwardSpeed too much, the walking animation may skip or pause, especially when the bot is walking up and down slopes.
#6
However, the anims only stop when they are close to you.
08/28/2005 (1:16 pm)
Yes, my bots walk at a speed of 3. However, the anims only stop when they are close to you.
#7
Check the pickActionAnimation() and updateAnimation() functions in player.cc - I added a walking bot and put a quick and dirty check in these functions: if ((isGhost()) && (mVelocity.len() < 0.1)) Con::errorf("(update animation)velocity < 0.1"); If memory serves me correctly, you should see that the timing of the animation skips correspond to these errors and the client and server velocity values differ. Unfortunately, I never got around to doing a fix, so I'd be interested in your/others comments on this.
08/28/2005 (6:30 pm)
Okay - my bots also walk at speed 3 and I think I have been having a similar problem (it does not appear to happen with the player either). There was a thread a while ago about this - I've searched but couldn't find it, although I do remember Ben Garney mentioning that they found it too, thought it might be some sort of problem involving networking but didn't track it down. From my investigations, it seemed that the mVelocity was being set to zero, or too low, for Ghosts with low walk/run speeds; this caused the animation to stop while the character was still translating (had an mVelocity.len() < 0.1). Check the pickActionAnimation() and updateAnimation() functions in player.cc - I added a walking bot and put a quick and dirty check in these functions: if ((isGhost()) && (mVelocity.len() < 0.1)) Con::errorf("(update animation)velocity < 0.1"); If memory serves me correctly, you should see that the timing of the animation skips correspond to these errors and the client and server velocity values differ. Unfortunately, I never got around to doing a fix, so I'd be interested in your/others comments on this.
#8
Sorry if this is all obvious but maybe my experiences will help.
I had similar problems in my game with animations not playing and AI skipping about all over the place. All of the issues came down to the issue of clients not correctly replicating what was going on on the server. The server keeps the absolute values for everything with the client getting regular updates but having to interpolate to work out inbetween states. If a developer starts trying to do something which the original game didn't allow for - e.g. characters moving really slow or really fast or in unusual movement patterns or having new animations then the prediction code on the client will probably get it wrong. Either because the data sent to the client is not accurate enough or missign altogether. The animations don't play and characters skip about all over the place. To fix these problems one needs to go through the network code, make sure ythey understand it then mod it appropriately. Note that I found it quite difficult to work out what is going on at first and I am still not 100% sure so I wouldn't want to advise on specific problems. As far as I can tell problems like this usually come about because the network layer in Torque is heavily optimised for a particular type of game - Tribes I guess? E.g. the data which is sent between client and server is cut down to the absolute minimum with accuracy rounded up or down accordingly.
Note that even on a SP game the client/server model is still operating in torque with data being "sent" between the two even though both are running on the same box.
Hope this helps
BTW anyone ever produced a resource which describes the network code in a simple to understand way?
08/28/2005 (7:56 pm)
Yes I was about to post and say that this probably something to do with replicating data across the network. Sorry if this is all obvious but maybe my experiences will help.
I had similar problems in my game with animations not playing and AI skipping about all over the place. All of the issues came down to the issue of clients not correctly replicating what was going on on the server. The server keeps the absolute values for everything with the client getting regular updates but having to interpolate to work out inbetween states. If a developer starts trying to do something which the original game didn't allow for - e.g. characters moving really slow or really fast or in unusual movement patterns or having new animations then the prediction code on the client will probably get it wrong. Either because the data sent to the client is not accurate enough or missign altogether. The animations don't play and characters skip about all over the place. To fix these problems one needs to go through the network code, make sure ythey understand it then mod it appropriately. Note that I found it quite difficult to work out what is going on at first and I am still not 100% sure so I wouldn't want to advise on specific problems. As far as I can tell problems like this usually come about because the network layer in Torque is heavily optimised for a particular type of game - Tribes I guess? E.g. the data which is sent between client and server is cut down to the absolute minimum with accuracy rounded up or down accordingly.
Note that even on a SP game the client/server model is still operating in torque with data being "sent" between the two even though both are running on the same box.
Hope this helps
BTW anyone ever produced a resource which describes the network code in a simple to understand way?
#9
1) When there are too many AiPlayers on screen
2) When the framerate is too low
In #2, my AiPlayers won't play the forward animation at all. I didn't have the time to look at it, but I think there is a fundamental problem in the way non-client controlled players play their animations on the client-side. It looks like when there's a big delay between updates (due to networkd-load or low framerate), the AiPlayer will re-start the walk animation, even when it looks like it's moving properly.
08/29/2005 (8:39 am)
I noticed this problem happening in two situations: 1) When there are too many AiPlayers on screen
2) When the framerate is too low
In #2, my AiPlayers won't play the forward animation at all. I didn't have the time to look at it, but I think there is a fundamental problem in the way non-client controlled players play their animations on the client-side. It looks like when there's a big delay between updates (due to networkd-load or low framerate), the AiPlayer will re-start the walk animation, even when it looks like it's moving properly.
#10
08/29/2005 (8:53 am)
Manoel - You are correct. I discovered the same thing yesterday.
#11
Manoel - Yes, I too have noticed that 1 and 2 (the framerate in particular) effect the problem.
08/31/2005 (9:15 pm)
Tony- I'd definitely agree with you about the specialised network layer causing the problems. The rounding problem is something else I looked at - most of the problems I had stemmed from the player velocity on the client being set to 0 and causing the current animation to pause and then restart. I can't remember, but it may have had something to do with this http://www.garagegames.com/mg/forums/result.thread.php?qt=25677 (sorry, I looked at this a long time ago, and can't really remember what I found).Manoel - Yes, I too have noticed that 1 and 2 (the framerate in particular) effect the problem.
Torque Owner Brian "Bazz" Staudinger
Did you try the normal orc model?
Do you use an AImanager?