PlayThread problems on characters
by Phoenix Online Studios · in Torque Game Engine · 11/18/2006 (8:53 pm) · 9 replies
Currently struggling with animation issues...
I'm trying to get facial animations working on top of the action thread of aiPlayers. The only viable way to do this seems to be to use setActionThread for the full-body animations and then playThread for the facial animation. Initially I did this with two script calls right after each other (first a setActionThread on one animation, then a playThread on another) but the effect was that only one a brief glimpse of the facial animation showed and then it went back to the standard position. Then I tried it with a short delay in between, and it worked.
I have a theory about this, and it's that if you call playThread during the time the action animation is in transition to its new position, the animation gets aborted or stops working when the model reaches the start position of the new action thread animation. So you must delay the playThread call for a short duration of time (it's hard-coded in player.cc) until you start it. Might be useful to know...
The next problem to solve is to get transitions working on a playThread-type script call. Right now the facial animation just snaps to its start position and there appears to be no way to get transitions via the provided script functions, although I haven't seen this mentioned in any documentation and ShowToolPro even allows you to play around with transition times. I'm still looking for a working solution to that problem, but so far I haven't seen any engine modifications posted that could solve this. Digging into the engine code to add this functionality yourself seems to be the only working solution.
I'm trying to get facial animations working on top of the action thread of aiPlayers. The only viable way to do this seems to be to use setActionThread for the full-body animations and then playThread for the facial animation. Initially I did this with two script calls right after each other (first a setActionThread on one animation, then a playThread on another) but the effect was that only one a brief glimpse of the facial animation showed and then it went back to the standard position. Then I tried it with a short delay in between, and it worked.
I have a theory about this, and it's that if you call playThread during the time the action animation is in transition to its new position, the animation gets aborted or stops working when the model reaches the start position of the new action thread animation. So you must delay the playThread call for a short duration of time (it's hard-coded in player.cc) until you start it. Might be useful to know...
The next problem to solve is to get transitions working on a playThread-type script call. Right now the facial animation just snaps to its start position and there appears to be no way to get transitions via the provided script functions, although I haven't seen this mentioned in any documentation and ShowToolPro even allows you to play around with transition times. I'm still looking for a working solution to that problem, but so far I haven't seen any engine modifications posted that could solve this. Digging into the engine code to add this functionality yourself seems to be the only working solution.
#2
Our facial animations are exported as blend animations. There may be other ways to get it to work, but this was the successful path for us.
All calls to set a new animation use transitionToSequence(...) (although setSequence will also work, depending on what you want).
Hope this is helpful. Good luck.
11/20/2006 (9:54 am)
We do facial animation via calls in the code. Our facial animations are exported as blend animations. There may be other ways to get it to work, but this was the successful path for us.
All calls to set a new animation use transitionToSequence(...) (although setSequence will also work, depending on what you want).
Hope this is helpful. Good luck.
#4
11/20/2006 (1:15 pm)
Yeah, I've tried to use transitionToSequence like that. Unfortunately I have not managed to get smooth transitions. It just snaps to whatever animation you start, like a setSequence. Looking at how it's used in player.cc and showTSShape.cc I cannot see anything that I'm doing wrong. The animations are not blend animations though, they are short looped animations. But they do smooth transitions in ShowTool so I can't see a reason for it not to work. I have confirmed that one is being played on the same thread as I call the next one, but there is no transition when I switch to another one.
#5
Are the animations shorter than the transition time? (Unlikely, but thought I'd ask).
Are you playing multiple threads that animate some of the same nodes? We tried that initially. It didn't consistently work, thus we went to blend animations. The blend threads play after the other threads animate, thus we got consistent results. For non-blended animation threads, it wasn't always the same as to the order that the threads animated. (Please note I didn't spend exhaustive time confirming that.). Hope some of this makes sense.
For what it's worth, transitionToSequence works as expected for us.
11/21/2006 (9:42 am)
That's a weird one. If it works in ShowTool, it's hopefully something simple to fix.Are the animations shorter than the transition time? (Unlikely, but thought I'd ask).
Are you playing multiple threads that animate some of the same nodes? We tried that initially. It didn't consistently work, thus we went to blend animations. The blend threads play after the other threads animate, thus we got consistent results. For non-blended animation threads, it wasn't always the same as to the order that the threads animated. (Please note I didn't spend exhaustive time confirming that.). Hope some of this makes sense.
For what it's worth, transitionToSequence works as expected for us.
#7
Myself, I could only play it once. The problem is related to the networking code, in particular ShapeBase::unPack () and the for loop which iterates trough all the threads.
11/21/2006 (11:44 am)
Many say that they have no problems whatsoever, and others say it only plays once, and then not at all - etc etc.Myself, I could only play it once. The problem is related to the networking code, in particular ShapeBase::unPack () and the for loop which iterates trough all the threads.
#8
Thing is, i have also noticed this not working in 1.5 ETC..
11/21/2006 (12:22 pm)
Can you expand on that?Thing is, i have also noticed this not working in 1.5 ETC..
#9
Playing multiple threads that animate some of the same nodes? Yeah, I guess so. There is a long, looping animation played as the "idle" action thread animation, controlling the entire character, and the animations I'm trying to play with transitions are only controlling the facial nodes.
I have now tried blended versions of the same animations, and while there were no changes in the game, something interesting happened in ShowToolPro: Transitions won't work there either, using the blended versions! This would suggest that it's a problem with our animation setup I guess.
But I've also tried it on the standard orc character, just to determine if it's just our models. The orc does transition smoothly between its animations (including full-body ones) in ShowTool, and obviously does so in its actionThread in the game as well. But when using my code to transition between animations, such as the different death sequences, it still jumps immediately between them.
What I have been trying to achieve here is an extension of the standard playThread code, to make transitionToSequence animation on ALL animated shape types, so I've put the code in shapeBase.cc, but I'm just about ready to give up on that and try adding code to player.cc instead. Any thoughts on this?
11/21/2006 (12:27 pm)
Are the animations shorter than the transition time? Well, the original animations I tried are 1 second long and I set the transition time to 1 second in the engine to make it clearly visible if it's working.Playing multiple threads that animate some of the same nodes? Yeah, I guess so. There is a long, looping animation played as the "idle" action thread animation, controlling the entire character, and the animations I'm trying to play with transitions are only controlling the facial nodes.
I have now tried blended versions of the same animations, and while there were no changes in the game, something interesting happened in ShowToolPro: Transitions won't work there either, using the blended versions! This would suggest that it's a problem with our animation setup I guess.
But I've also tried it on the standard orc character, just to determine if it's just our models. The orc does transition smoothly between its animations (including full-body ones) in ShowTool, and obviously does so in its actionThread in the game as well. But when using my code to transition between animations, such as the different death sequences, it still jumps immediately between them.
What I have been trying to achieve here is an extension of the standard playThread code, to make transitionToSequence animation on ALL animated shape types, so I've put the code in shapeBase.cc, but I'm just about ready to give up on that and try adding code to player.cc instead. Any thoughts on this?
Torque Owner Stefan Lundmark