Game Development Community

Smooth animation transitions

by Rubes · in Torque Game Engine · 05/15/2007 (8:42 am) · 12 replies

I've been experimenting with NPC animations (using the aiPlayer class) and I've come across something that I wanted to double check. There's not a lot of info available in the docs or forums on this, as far as I can tell.

What I would like to do is to create two separate animation threads for an NPC: one thread is used for full body animations, and another is used for playing speech animations (which only involve the mouth). I thought I would do this using the playThread() method. One thing I need from this setup is to be able to play different full body animations in the first thread which transition smoothly from one animation to the next.

When I use ShowTool, I can get these animations to transition smoothly using the "transition to sequence" option. But in the game, using the playThread() method, I can't get smooth transitions. The animations just jump from one to the next.

I've noticed that if I use the setActionThread() method instead of the playThread() method, I do get smooth transitions. That works well enough, as long as I play the mouth animations using playThread().

Is that basically the way animations are set up in the engine? The only way to have smooth transitions is to use setActionThread() instead of playThread()? Or is there some way to get smooth transitions using playThread() that I don't know about?

Thanks....

#1
05/15/2007 (9:15 am)
SetActionThread is for your full body animations, or more often the spine and lower body nodes. Running, jumping, etc. It's driven by pickActionAnimation in the player class.

Quote:I've noticed that if I use the setActionThread() method instead of the playThread() method, I do get smooth transitions. That works well enough, as long as I play the mouth animations using playThread().

Yes, you should blend playThread animations on top of action animations for your facial nodes. There is however no transitionToSequence method for playThread animations. There's also a bug in the engine where the animations are not reset properly when the state flips to stAtEnd. This results in you only being able to play a particular non-cyclic playThread animation once. It's a simple one line fix though.
#2
05/15/2007 (9:19 am)
Quote:There's also a bug in the engine where the animations are not reset properly when the state flips to stAtEnd. This results in you only being able to play a particular non-cyclic playThread animation once. It's a simple one line fix though.

I've noticed this; I have to call stopThread at the end in order to play the same animation a second time. Do you know the specific fix?
#3
05/15/2007 (9:27 am)
Sure, here's the thread with the fix.

garagegames.com/mg/forums/result.thread.php?qt=60472
#4
05/15/2007 (9:29 am)
Doh! that's TGE-A only.
is it a TGE issue too ?
#5
05/15/2007 (9:32 am)
Yeah, what he said!
#6
05/15/2007 (9:47 am)
The non-cyclic animation bug obviously exists in both codebases. I can say with a 99% certainty that the code is identical in both versions. However as I don't have TGE installed atm I can't say that with 100% certainty. If an employee comes in from the bbq on garagegames new tiki-tent patio they can delete it if need be.

oid ShapeBase::advanceThreads(F32 dt)
{
   for (U32 i = 0; i < MaxScriptThreads; i++) {
      Thread& st = mScriptThread[i];
      if (st.thread) {
         if (!mShapeInstance->getShape()->sequences[st.sequence].isCyclic() && !st.atEnd &&
             (st.forward? mShapeInstance->getPos(st.thread) >= 1.0:
              mShapeInstance->getPos(st.thread) <= 0)) {
            st.atEnd = true;
	    updateThread(st);
			
             if (!isGhost()) {
           [b]stopThread(i);[/b]
               char slot[16];
               dSprintf(slot,sizeof(slot),"%d",i);
               Con::executef(mDataBlock,3,"onEndSequence",scriptThis(),slot);
            }
         }
         mShapeInstance->advanceTime(dt,st.thread);
      }
   }
}
#7
05/15/2007 (9:54 am)
Looks the same to me as TGE...thanks for the fix.
#8
05/15/2007 (9:56 am)
Awesome, thanks.
that matches my TGE 1.3 code exactly. except for the fix, of course.

they really get a tiki tent patio ?
#9
05/15/2007 (10:00 am)
How'd you hear about the tiki tent patio? [*glances both ways*]
#10
05/15/2007 (10:54 am)
Quote:How'd you hear about the tiki tent patio? [*glances both ways*]

i19.tinypic.com/6bmt8uo.jpgLol! I have my sources. In fact here's a photo taken last night, of garagegame's senior engineer hard at work on the opengl renderer for TGEA.
#11
05/15/2007 (10:59 am)
*wipes tear from eye* That's the best OpenGL implementation I ever saw.
#12
05/15/2007 (12:15 pm)
Cool, I didn't realize they had hired a female senior engineer. Who's the guy?