Game Development Community

Animation Transition not working.

by Markus Nuebel · in Torque Game Engine · 12/12/2004 (4:03 am) · 21 replies

Hi.

I have added a new non-cyclic animation to my orc player which is played fine, when the the user presses a key.
At the end of the animation, the orc stays in that position, until the user releases the key.

Now I want to blend the current orc over to the new animation (which is also not cyclic), but all I get is an immediate switch to the new animation.

Although I am using:

TSShapeInstance:transitionToSequence(newAnimation, 0.0, 1.5, true);

The animation just switches over to the new one, as if I had called
TSShapeInstance:setSequence( newAnimation, 0.0);

Anyone an idea, what to do, to get a non cyclic animation blend over to another animation?

Thanks.

-- Markus
Page «Previous 1 2
#1
01/05/2005 (10:01 am)
Just in case someone is interested:

transitionToSequence() does not support "blend animations".

It only works on "non-blend animations" Like the "run" and "sidestep" animations.

-- Markus
#2
09/17/2005 (8:28 pm)
It's part of the internal 3space shape rendering library. It is not exposed to script directly, though methods that are exposed to script might call it.
#3
01/19/2006 (12:16 am)
TSShapeInstance::transitionToSequence(TSThread * thread, S32 seq, F32 pos, F32 duration, bool continuePlay)

Can anyone explain what does the params : duration, and continuePlay do?

Thanks.
#4
07/11/2006 (10:32 am)
Markus - did you ever get a response to why the transitionToSequence does not work. It plays the animation right away?
#5
07/11/2006 (2:40 pm)
At a guess - duration is how long the transition should last, and continuePlay is a flag indicating whether the previous animation should keep playing during the transition or not.

You should be able to test this very easily by playing one animation, then triggering a call to transitionToSequence from, say, a script method. I'd be interested in hearing what the definitive answer is!
#6
07/12/2006 (11:42 am)
Hi Ben -
I have tried every combination you can imagine to make this work.
Look at thread for my code.

http://www.garagegames.com/mg/forums/result.thread.php?qt=47517

But I cannot get transitions to work at all. I have set the flag "continuePlay" to 0 and 1 and set the duration from .25 to 10 seconds. Nothing.


Anyhelp would be appreciated.
#7
07/12/2006 (4:08 pm)
See my reply to your thread.

Also - do consider single stepping through the code for that call in the debugger. It'll help you get a clue as to what's going wrong and what should be happening.
#8
07/21/2006 (9:12 pm)
I tested with 2 non-blended sequences. My observations suggests that

- With continuePlay=false, the transit-to animation does not affect the transition. When continuePlay=true, during the transition, the transit-from animation will transit to the transit-to animation.

Still trying to figure out the duration param. Seems like duration/timescale = the time for the transition to the new sequence.
#9
07/21/2006 (11:45 pm)
Wouldn't duration be in milliseconds like most other things in the engine?
#10
07/21/2006 (11:50 pm)
I'd guess it's either milliseconds, or expressed in the transitioned-to-thread's T.

Would be curious to hear what you find out. Thanks for involving us thus far!
#11
07/25/2006 (11:27 am)
Ron -
Can you post the test source code you are using that is working?
#12
07/29/2006 (1:05 pm)
Ron -
Have you found out anything more on this?
#13
07/30/2006 (2:56 am)
***Disclaimer - I don't professs to completely understand how this works.

What I did was to test with a small dts with 2 seqs. Seq A moves a small bead vertically upwards, Seq B moves it horizontally.


What I found out. (the following assumes you are playing Seq A, then transit to Seq B)

1) continuePlay = false means the animation will "rewind" Seq A and then play Seq B. The "rewind" depends on the value of duration. Duration seems to be the time (in secs) for Seq A to rewind, 0.0 means return instantly; indirectly controlling how fast Seq A "rewinds".

When continuePlay=true, Seq A "rewinds" while Seq B plays at the same time, creating a composite animation of sorts. Using my test dts as example, if I first play Seq A to move the bead up vertically, and then call TSshapeInstance::transitToSequence with Seq B and continuePlay=true, the bead moves down and horizontally sideways at the same time, you will see the ball tracing a curve. The exact motion depends on your duration (how fast Seq A rewinds) and timescale (how fast Seq B plays).

Note 1: The seqs in this test dts and my actual game dts are non-blended, with 2 frames each. These 2 frames are are identical, i.e. no animation inbetween.

Note 2: For some reason, I had to turn on blending in the engine code ( TSshapeInstance::setBlendEnabled(true) ) for the seq to play. Maybe its because I'm simultaneous using other animation threads which are playing blended sequences.

Hope this helps.
#14
07/30/2006 (4:27 pm)
Thanks for the write-up, Ron!

To clarify - I don't think what you're seeing is the sequence "rewinding", but rather its effect being faded out and replace with the effect of the other animation (or the root pose if the other animation isn't affecting something). So in your case you do see the bead returning to the position it was at at the first frame of the original animation, but if you were applying this transition to, say, a running character you'd not see any frames of "backwards running" happening.
#15
08/22/2006 (11:56 am)
I've been struggling with animation transitions as well. Is there a chance that someone could post the final version of the source code that they are using to get this to work. Ron, did you expose this functionality to script? If so, exactly which function did you expose?
#16
11/19/2006 (5:03 pm)
I have tried a solution very similar to Clara's. Based on what the player code does for action threads and the ShowTool code for the Thread Controls window, plus comparisons with the normal code for playing threads, it looks like everything is ok. I even added some debug output in tsThread.cc to make sure everything looks ok, and it does. But still, when using it on aiPlayers, there is no transition. The animation starts immediately, just like if you called setSequence. Suspecting that it might be something player-specific messing up transitions, I tried disabling the updating of player action animations. But even then, no transitions. I have tried all combinations of suggested solutions here and in the other thread but it still does not work. My animations are correctly set up and work perfectly in ShowTool.
#17
06/04/2007 (1:37 am)
Exact same problem here. Transitions work flawlessly in ShowTool but do not transition at all on players.

Switched to non-blend animations and works great now! Thanks for this thread Markus, this thing has been bugging me for sooooo long!
#18
07/05/2007 (10:15 am)
Yves -

Do you have sample code on the 'transitionToSequence'. I cannot get it to work still. On am using AIPlayer. The call is simple.

bool ShapeBase::setThreadTransitionSequence(U32 slot,S32 seq,bool reset)
{
Thread& st = mScriptThread[slot];
if (st.thread && st.sequence == seq && st.state == Thread::Play)
return true;

//setMaskBits(ThreadMaskN << slot);
//st.sequence = seq;
shapeInstance->transitionToSequence( st.thread, seq, 1, 1.50, true );
}


Initially I have the walk animation running, then via script-> calls console function which calls above routine to transition to another animation. Yet no animation starts the old walk animation continues.
if I rem out the setmaskbits and st.sequence lines, then the second animation runs, but with no transitions.

This has been a problem for a very long time. Any help would be appreciated.
#19
07/05/2007 (10:59 am)
OT Note: don't hit the refresh button on a page that has the "Post a Reply" edit window up--it re-posts your last post :)

By default, the engine is set up to over-ride any "unique" animations with procedurally indicated animations...meaning that if you are waving at someone (unique animation), and you start walking forward, the wave animation is cancelled, and we go back to procedural animation (combining multiple blend animation threads regarding movement, etc based on game conditions).

What is most probably going on is that you are transitioning to the new animation, but 32 milliseconds later (max), the engine is recognizing a need for procedural animation, and that has a higher priority, so it over-rides your unique animation that is currently running.

What is the specific use case for you? In other words, what is the animation you want to transition to, what are the game states (is the AIPlayer still moving, etc), and why do you want your unique animation to play?
#20
07/05/2007 (6:51 pm)
Hi Stephen-
Sorry about that.
I was only using the walk animation as a test. I have a number of animations like open_hands_and_Wave, scratch, etc. I want my animations to smoothly transition from one animation to another. Right now when I switch using the standard script playthread, you can see a jerking motion between the animations as they play immediatly with no smooth transitions.

When I am playing these animations, does AI player is not moving (not calling %char.setMoveDestination).
the character is idle, and is playing the root animation. I follow the steps below:
1) I use the playthread animation to play the "open_hands_and wave" animation
2) When this animation completes, I call the above function 'setThreadTransitionSequence' which is called via console method. I want to transition to the "scratch" animation smoothly. But I get no movement at all for the new animation.
It's like it ignores the call to 'shapeInstance->transitionToSequence'. These animations are non-blended and use the same priority.

If I load the torquedemo.exe passing - SHOW as a parameter. I can test the transitions like I can in showtool and it does work this way.
Page «Previous 1 2