Game Development Community

Starting to not trust animationDone (fixed)

by Kevin Mitchell · in Torque 3D Professional · 03/03/2013 (9:26 pm) · 8 replies

Every time I play an animation it seems to instantly fire the second I start an animation.

Is there a known issue with this?

#1
03/04/2013 (5:19 am)
not sure what your issue is, could you word it a bit better and explain animation what on? an object, player or mounted object?

an instantly fire? fire what, the animation, the mounted object?

are you saying the player fires its weapon the instant the animation is played?

or the animation fires the instant you tell it to? (Isn't that supposed to happen?)
#2
03/04/2013 (6:14 am)
Sorry I posted that moments before passing out.

I have a climb up animation, of which i have a link in the animationDone call back to do to process some things when the animation is done. The problem is that as soon as the animation is called the animationDon call back is called.
I never see that animation play what so ever. I even expanded the animation to be 4 times as long ad i do not see it.

If i look at the animation in the shape editor it plays just fine.

One thing i noticed is that the mActionAnimation.atEnd is never set true. And that there are several conditions that can get you into the animationDone call back handing:



if (mActionAnimation.action == RPGPlayerData::NullAnimation ||
   ((!mActionAnimation.waitForEnd || mActionAnimation.atEnd)) &&
     !mActionAnimation.holdAtEnd && (mActionAnimation.delayTicks -= !mMountPending) <= 0)
   {

This looks like:

If there is no animation set.
If Wait for end is not set
Or if atEnd is not set.

My confustion is if the functionality of the section is to aleart an animation being complete why would atEnd never be triggered. Also why would it be linked to "Wait for End" being false, making me believe that it may fire the animation done if we are not waiting for it to end. Which confuses me on why we would just not use the animation done only if "Wait for End" was true. Would this not mess up people that are trying to use the animationDone for end of animation action triggering?
#3
03/04/2013 (3:52 pm)
Its an old thread and took some finding but this may be of help
its pre T3D alpha code but the explanations are the same

www.garagegames.com/community/forums/viewthread/73223

Hope it helps
#4
03/04/2013 (5:56 pm)
ok, tried to do a little testing.

put in /scripts/game.cs
function animtest()
{
   %myclient = LocalClientConnection.player;
   echo(%myclient);
   commandToServer('playThread', %myclient, "reload" );
}
put in /server/game.cs
// This function is called by typing animtest in the console, the animation fires.
function serverCmdplayThread(%this, %client, %animation )
{
   echo(%this SPC "---" SPC %client SPC "---" SPC %animation);
   %client.setActionThread(%animation, false, false);
}

function SoldierDAE::animationDone(%this, %object)
{
   echo("S" SPC %this SPC %object);
}

function Armor::animationDone(%this, %object)
{
   echo(%this SPC %object);
}

function PlayerData::animationDone(%this, %object)
{
   echo("P" SPC %this SPC %object);
}

animationDone is never being called by any of these functions, I know at least 2 of these are prolly wrong but have no idea why none of them are getting fired off, any ideas anyone?

never mind, its late and I figured out I'm using the client player id, not the server player id, I'll take another pass at it 2morrow :-)
#5
03/04/2013 (7:25 pm)
That first link you gave me actually got me in the right direction. I had to modify pickactionanimation:

bool forward = true;
   bool wait = false;
   U32 action= RPGPlayerData::RootAnim;
   bool fsp = false;
   
   //Added Climbing Animation Check
   if( mClimbing )
   {
	   pickBestClimbMoveAction(RPGPlayerData::ClimbRootAnim, RPGPlayerData::ClimbRightAnim, &action, &forward,&wait);
   }else
   // Jetting overrides the fall animation condition
   if (mJetting)
.
.
.
.
.
.
.
   else if ( mPose == SprintPose )
   {
      pickBestMoveAction(RPGPlayerData::SprintRootAnim, RPGPlayerData::SprintRightAnim, &action, &forward);
   }
   
   setActionThread(action,forward,false,wait,fsp);
}

Works like a charm now. Had to modify the animation processing since it ignores all animation that are part of the initial animation struct.

if (mActionAnimation.action == RPGPlayerData::NullAnimation ||
   ((!mActionAnimation.waitForEnd || mActionAnimation.atEnd)) &&
   !mActionAnimation.holdAtEnd && (mActionAnimation.delayTicks -= !mMountPending) <= 0)
   {
	   //RPG EDIT
	   if(mActionAnimation.atEnd && mUpdateAnimation){
		   mUpdateAnimation=false;
		  // AdjustAnimationPosition();
	   }
	   //RPG EDIT
	   if(	mActionAnimation.atEnd && isServerObject() && 
	   	mActionAnimation.action && mDataBlock->actionList[mActionAnimation.action].name){
	   	
		mDataBlock->animationDone_callback( this,mDataBlock->actionList[mActionAnimation.action].name );
		
	   }else{
		  //The scripting language will get a call back when a script animation has finished...
		  //  example: When the chat menu animations are done playing...
		  if ( isServerObject() && mActionAnimation.action >= RPGPlayerData::NumTableActionAnims ){
				mDataBlock->animationDone_callback( this,mDataBlock->actionList[mActionAnimation.action].name );
		  }
	   }
      pickActionAnimation();
   }


I find it interesting that you have to make it wait or else you get a fault call back. I'll have to note this some where.
#6
03/05/2013 (6:04 am)
Glad I could help, Its not a good Idea writing test code at 1am Lol

I think the wait is so it can finish any animation its already playing, so that one doesn't trigger the callback
#7
03/05/2013 (2:15 pm)
Actually you need to do wait or else the call back happens instantly. And your animation skips.
#8
03/06/2013 (6:34 pm)
Had to modify this to send the done on the client section of the code as server did not set the atEnd trigger.


if (mActionAnimation.action == RPGPlayerData::NullAnimation ||
   ((!mActionAnimation.waitForEnd || mActionAnimation.atEnd)) &&
   !mActionAnimation.holdAtEnd && (mActionAnimation.delayTicks -= !mMountPending) <= 0)
   {
	   //RPG EDIT
	   if(mActionAnimation.atEnd && mUpdateAnimation){
		   mUpdateAnimation=false;
		  // AdjustAnimationPosition();
	   }
	   //RPG EDIT
	   if(	mActionAnimation.atEnd &&/* isServerObject() && */
	   	mActionAnimation.action && mDataBlock->actionList[mActionAnimation.action].name){
	   	
		mDataBlock->animationDone_callback( this,mDataBlock->actionList[mActionAnimation.action].name );
		
	   }else{
		  //The scripting language will get a call back when a script animation has finished...
		  //  example: When the chat menu animations are done playing...
		  if ( isServerObject() && mActionAnimation.action >= RPGPlayerData::NumTableActionAnims ){
				mDataBlock->animationDone_callback( this,mDataBlock->actionList[mActionAnimation.action].name );
		  }
	   }
      pickActionAnimation();
   }