Game Development Community

Problem playing animations on AI and isGhost() questions

by Tony Oakden · in Torque Game Engine · 01/11/2005 (6:36 pm) · 3 replies

I can't get custom animations to play reliably on AI characters in game. I've created a new character with a walk cycle and an attack animation. The walk cycle plays fine but the attack animation only plays intermitently even though the attack is definetly getting triggered correctly. I'm triggering the animation in native code from within a function in player.cc ( can't remember the function name but it also contains the existing code for controlling the jump) and I used the existing code for triggering the jump animation as my template.

To sanity check this I've changed the player data block to point at my new character. In this case all the animations play fine. I tested the attack animation by temporarilly hacking the code to play my attack animation in place of the jump and it plays fine on the player. As a further check I hacked the AI to play the attack animation when the AI jumps so that it uses virtually the same code path as the player. In that case the animation DOES NOT play reliably when the AI jumps. So the bug is definetly something specific to the way the AI sets up the animation data not the animation data itself or the animation code all of which work fine in isolation.

After some experimentation it appears that a certain function "isghost()" has to return true for the animation to play. What I found was that this function usually returns false and only occasionally true hence the animation only occasionally plays (about 1 in 6 attacks). I assume this function is something to do with clients verifying that the object exists on the server but the code is pretty complex so it's difficult for me to be sure of exactly what is going on.

So my questions are:

Is there some special magic I have to do to get my animations to play on AI characters?

Does anyone know what isGhost() is supposed to do? Should it be returning the same value reliably? If so any idea why it's returning duff values in my engine? AFAIK I haven't changed anything in native which could explain this behaviour. I'm running the game as combined client/server

Has anyone had any luck creating custon AI characters with custom animations and getting them to play reliably in game?

I've spent a lot of time on this now and I am really starting to get to the limits of my knowledge of torque. Which is annoying as I've got loads of other tasks to do on my game which are well within my ability but I really need to get this nailed first.

Thanks in advance :)

#1
01/12/2005 (3:06 pm)
As far as i know.. isGhost returns true? if the code is running for the client side

and false if its running on the server

some code should only be run on one or the other thats why it is there

but alot of the code is run for both the client and the server, thats why sometimes it returns true and others false..

i dont know what is going on with your animation
i am also having sierious issues with my animations..

if i am moving to slow it does this weird skipping
#2
01/12/2005 (5:41 pm)
Thanks Charles that's the conclusion I had come to with regards to isGhost. Just to be clear the walk cycle plays fine on the AI but when the AI jumps the jump animation only occasionally triggers. It definetly only triggers when isGhost() returns true but this does not neccessarily mean there is something wrong with that function. THe same character data works fine on the player so it's not the data which is at fault.

I wonder if my problem is that the AI is not in relevance on client properly and so the server is not sending the updated animation sequence to the cleint? Strange though becuase the physical side of the action (the actual jump) is getting replicated perfectly.
#3
09/11/2007 (6:05 am)
I am having this same challenge. I have custom characters with custom animations, and am trying to play them across a network. The interesting thing to me is that when I initialize a game on one PC with no outside network players it works perfectly, all animations play when they are called to by script. But when I try to have the characters perform their animations across a network, the animations fail to play. I have tried playThread and setActionThread.

Do I have to call the animations on each clients ghost objects specifically? What is the reason for this? Can someone please help me out?