Game Development Community

animations only paying after trigger released

by Donald Teal · in Torque 3D Professional · 03/14/2010 (2:44 pm) · 48 replies

I have added some animations to go with the flight code for my player model. I am using T3D1.1a.

in default.bind.cs I have
function glideTrigger(%val)
{
   $mvTriggerCount5++;
}

moveMap.bind( keyboard, g, glideTrigger );

model goes into flight position but doesn't play the animation untill after the trigger is released.
all animations play fine in model editor.

the flight mechanics work fine and are designed to be enabled only when trigger is pressed. when trigger is
released it goes into fall state.

EDIT: ok it seems that the animation is trying to play but keeps resetting while the 'g' key is down.
what would be a better way to do this so the animation can cycle as long as the key is pressed and not
keep resetting?
Page «Previous 1 2 3 Last »
#1
03/15/2010 (6:06 am)
Is it resetting while the key is held down or is it just resetting on the and key up event?

If so take a look here...
http://www.torquepowered.com/community/forums/viewthread/22010
#2
03/15/2010 (6:31 am)
it is resetting while the key is held down. once you release the key it plays the animation
#3
03/18/2010 (8:14 am)
I am still trying to figure this issue out. I currently have the code below in default.bind.cs. it now works as a toggle and still never plays the animations until it is released. added echo(%val); to see if it was doing something it wasn't supposed to. console just gets the expected 1 for pressed and 0 for released. any help would be great. have searched the forums for similar issues but didn't find anything useful.

function glideTrigger(%val)
{
   echo(%val);
   
   if(%val==1)
   {
   $mvTriggerCount5++;
   }
   
   if(%val==0)
   {
   return;
   }

}

moveMap.bind( keyboard, g, glideTrigger );
#4
03/18/2010 (10:15 am)
mvTriggerCount5 has nothing to do with jetting unless you have coded this trigger manually.
For what I understand, you do your own physics using mvTriggerCount5 (respectively move->trigger[5]) ,your animation does not play,but your physics is fine.
Firstly check how setActionThread() control your sequence.It is possible that it is set and then reset by another sequence.
#5
03/18/2010 (10:34 am)
yes this is custom glide control. not using jetting. I will look into that.
#6
03/18/2010 (5:07 pm)
I am not seeing the sequence being reset by anything else but it is old code I am cleaning up from TGE. I am not extremely versed in c++ so its slow and tedious. Although I had a similar problem with my swimming animations and that was not a code issue. Was determined to me a model or animation issue. was not able to use the swim root animation with the swim movement animations. curious if this could be a similar problem. Have you seen that before?
#7
03/18/2010 (6:26 pm)
Donald, not sure if this is helpful, but have you added "glide" or whatever your anim is called to player.ccp actions?

Example of that and also good for fixing swim-root-sticking is here - linky
#8
03/19/2010 (7:54 am)
Donald, how do you set your sequence ?
#9
03/19/2010 (12:11 pm)
not sure exactly what you need to see but here is the code related to the animations

in player.cpp
bool Player::isActionAnimation(U32 action)
{
   if(getAction("root") == action ||
      getAction("run") == action ||
      getAction("back") == action ||
      getAction("side") == action ||
      getAction("look") == action ||
      getAction("head") == action ||
      getAction("fall") == action ||
      getAction("land") == action ||
      getAction("jump") == action ||
	   getAction("idle_combat") == action ||
	   getAction("swim")        == action ||
	   getAction("glide_idle_bank_left")  == action ||
	   getAction("glide_idle")  == action ||
	   getAction("glide_idle_bank_right")  == action ||
	   getAction("glide_walk_bank_left")  == action ||
	   getAction("glide_walk")  == action ||
	   getAction("glide_walk_bank_right")  == action ||
	   getAction("glide_run_bank_left")   == action ||
	   getAction("glide_run")   == action ||
	   getAction("glide_run_bank_right")   == action) 
	   {
      return true;
   }
   else
   {
      return false;
   }
}
U32 Player::getAction(const char* sequence)
{
   for (U32 i = 1; i < mDataBlock->actionCount; i++)
   {
      PlayerData::ActionAnimation &anim = mDataBlock->actionList[i];
      if (!dStricmp(anim.name,sequence))
      {
	     return i;
      }
   }
   return 0;
}
and
else if(mContactTimer > 10)
      {
            if(currentGlideSpeed != 0)
	         {
		         if(currentGlideSpeed == mDataBlock->minGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
				         action = getAction("glide_idle_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
				         action = getAction("glide_idle");
			         }
			         else if(currentBankSpeed > 0)
			         {
				         action = getAction("glide_idle_bank_right");
			         }
		         }
		         else if(currentGlideSpeed == mDataBlock->midGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
				         action = getAction("glide_walk_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
				         action = getAction("glide_walk");
			         }
			         else if(currentBankSpeed > 0)
			         {
				         action = getAction("glide_walk_bank_right");
			         }
		         }
		         else if(currentGlideSpeed == mDataBlock->maxGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
				         action = getAction("glide_run_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
				         action = getAction("glide_run");
			         }
			         else if(currentBankSpeed > 0)
			         {
				         action = getAction("glide_run_bank_right");
			         }
		         }
	         }
	         else
	         {
		            if (mContactTimer >= sContactTickTime)
	               {
		               // Nothing under our feet
			         action = PlayerData::RootAnim;
	               }
              }
         }

and in player.h
U32 getAction(const char* sequence);

and
bool isActionAnimation(U32 action);
   bool isIdleAnimation(U32 action);

#10
03/19/2010 (1:07 pm)
@Donald,

Just checking but you did update the animation count in player.h, yes? The nummoveaction table stuff.
#11
03/19/2010 (2:03 pm)
in old code it was "NumTableActionAnims = LandAnim + 1,"
now that causes 'NumTableActionAnims' : redefinition; previous definition was 'enumerator'

commented it out to get it to compile. wasn't sure what it needed to be changed to and was unable to find any info on it.
that must be the problem any guidance on how to get it back in?
#12
03/19/2010 (3:00 pm)
I just add 1 to the ActionAnimBits for each new anim and make sure it's in the list of animations somewhere above that (with the rest).
...
    { "prone_root" },  
    { "prone_forward" },  
    { "prone_back" },//yorks added  
    { "prone_side" },//yorks added 
...
...
ActionAnimBits = 13,//yorks changed from 9 
...

But you're probably doing something a bit more "indepth" than me
#13
03/19/2010 (5:22 pm)
ok added the 9 new animations to the list and added that to ActionAnimBits and still no animations. here are the changes I have made.

in player.h
glide_idle_bank_left,
	  glide_idle,
	  glide_idle_bank_right,
	  glide_walk_bank_left,
	  glide_walk,
	  glide_walk_bank_right,
	  glide_run_bank_left,
	  glide_run,
	  glide_run_bank_right,

added after
FallAnim,
      JumpAnim,
      StandJumpAnim,
      LandAnim,
      JetAnim,
and
ActionAnimBits = 9,

changed to
ActionAnimBits = 18,

now in player.cpp
I commented out
bool Player::isActionAnimation(U32 action)
{
   if(getAction("root") == action ||
      getAction("run") == action ||
      getAction("back") == action ||
      getAction("side") == action ||
      getAction("look") == action ||
      getAction("head") == action ||
      getAction("fall") == action ||
      getAction("land") == action ||
      getAction("jump") == action ||
	   getAction("idle_combat") == action ||
	   getAction("swim")        == action ||
	   getAction("glide_idle_bank_left")  == action ||
	   getAction("glide_idle")  == action ||
	   getAction("glide_idle_bank_right")  == action ||
	   getAction("glide_walk_bank_left")  == action ||
	   getAction("glide_walk")  == action ||
	   getAction("glide_walk_bank_right")  == action ||
	   getAction("glide_run_bank_left")   == action ||
	   getAction("glide_run")   == action ||
	   getAction("glide_run_bank_right")   == action) 
	   {
      return true;
   }
   else
   {
      return false;
   }

and changed getAction to PlayerData here
else if(mContactTimer > 10)
      {
            if(currentGlideSpeed != 0)
	         {
		         if(currentGlideSpeed == mDataBlock->minGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
						 action = PlayerData::glide_idle_bank_left;
				         //action = getAction("glide_idle_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
						 action = PlayerData::glide_idle;
				         //action = getAction("glide_idle");
			         }
			         else if(currentBankSpeed > 0)
			         {
						 action = PlayerData::glide_idle_bank_right;
						 //action = getAction("glide_idle_bank_right");
			         }
		         }
		         else if(currentGlideSpeed == mDataBlock->midGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
						 action = PlayerData::glide_walk_bank_left;
						 //action = getAction("glide_walk_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
						 action = PlayerData::glide_walk;
						 //action = getAction("glide_walk");
			         }
			         else if(currentBankSpeed > 0)
			         {
						 action = PlayerData::glide_walk_bank_right;
						 //action = getAction("glide_walk_bank_right");
			         }
		         }
		         else if(currentGlideSpeed == mDataBlock->maxGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
						 action = PlayerData::glide_run_bank_left;
						 //action = getAction("glide_run_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
						 action = PlayerData::glide_run;
						 //action = getAction("glide_run");
			         }
			         else if(currentBankSpeed > 0)
			         {
						 action = PlayerData::glide_run_bank_right;
						 //action = getAction("glide_run_bank_right");
			         }
		         }
	         }
	         else
	         {
		            if (mContactTimer >= sContactTickTime)
	               {
		               // Nothing under our feet
			         action = PlayerData::RootAnim;
	               }
              }
         }

like this it compiles but still have no animations.
and if I add this to the player.cpp I get error C2078: too many initializers player.cpp 147

{ "glide_idle_bank_left" }, 
   { "glide_idle" },
   { "glide_idle_bank_right" },
   { "glide_walk_bank_left" },
   { "glide_walk" },
   { "glide_walk_bank_right" },
   { "glide_run_bank_left" },
   { "glide_run" },
   { "glide_run_bank_right" },
#14
03/20/2010 (12:57 am)
In updateActionThread() ,after pickActionAnimation() is called, try to output the sequence number:

Con::printf("seqN = %i",mShapeInstance->getSequence(mActionAnimation.thread));

This information is valuable,because if your number is not set,your animation is not called at all.If it is set for a single tick - it means that it is reset.
#15
03/20/2010 (8:54 am)
hmm getting seqN = 4 thru 10 depending on the glide I am calling.
shouldn't it be seqN 10-18? that would be the 9 new animations.
idle in glide is seqN 7 and also when glide is turned off while gliding and fall kicks in the glide animation starts playing and still calls seqN 7

model is basically a biped with wings. when on ground walks in upright biped position. when glide is activated and not in contact with ground it goes into a horizontal position and the animations are the wings and such.
model is going into position just not animating. incase there was any confusion I hope this help clear that up and give a better understanding.
not sure if it has anything to do with the animation not playing or not but the model does reposition when in the glide state.
#16
03/20/2010 (10:23 am)
OK,instead of
action = PlayerData::your_animation;


call directly:
setActionThread(PlayerData::YourAnim, true, false, true,false,true);
#17
03/20/2010 (11:41 am)
ok well doing that cancled all glide positions. it stays in root animation and verticle. does not even go into glide position. and in seqN only gets 0 and 1.
#18
03/20/2010 (12:23 pm)
It means that your animation is reset by root/run.
You call setActionThread() manually and you set your animation,after that in the same tick another setActionThread() is called. I think this happens in pickActionAnimation()
#19
03/21/2010 (10:00 am)
here is the pickActionAnimation() I am just not seeing where its getting reset. thanks so much for trying to help.

void Player::pickActionAnimation()
{
   // Only select animations in our normal move state.
   if (mState != MoveState || mDamageState != Enabled)
      return;

   if (isMounted())
   {
      // Go into root position unless something was set explicitly
      // from a script.
      if (mActionAnimation.action != PlayerData::RootAnim &&
          mActionAnimation.action < PlayerData::NumTableActionAnims)
         setActionThread(PlayerData::RootAnim,true,false,false);
      return;
   }


   bool forward = true;
   U32 action = PlayerData::RootAnim;
   bool fsp = false;
   
   // Jetting overrides the fall animation condition
   if (mJetting)
   {
      // Play the jetting animation
      action = PlayerData::JetAnim;
   }
   else if (mFalling)
   {
      // Not in contact with any surface and falling
      action = PlayerData::FallAnim;
   }

//-----------------------------gliding edit------------------------
   else if(mContactTimer > 10)
   //if(mContactTimer > 10)
        {
        if(currentGlideSpeed != 0)
	         {
		         if(currentGlideSpeed == mDataBlock->minGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
						 setActionThread(PlayerData::glide_idle_bank_left, true, false, true,false,true); 
						 //action = PlayerData::glide_idle_bank_left;
				         //action = getAction("glide_idle_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
						 setActionThread(PlayerData::glide_idle, true, false, true,false,true); 
						 //action = PlayerData::glide_idle;
				         //action = getAction("glide_idle");
			         }
			         else if(currentBankSpeed > 0)
			         {
						 setActionThread(PlayerData::glide_idle_bank_right, true, false, true,false,true); 
						 //action = PlayerData::glide_idle_bank_right;
						 //action = getAction("glide_idle_bank_right");
			         }
		         }
		         else if(currentGlideSpeed == mDataBlock->midGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
						 setActionThread(PlayerData::glide_walk_bank_left, true, false, true,false,true); 
						 //action = PlayerData::glide_walk_bank_left;
						 //action = getAction("glide_walk_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
						 setActionThread(PlayerData::glide_walk, true, false, true,false,true); 
						 //action = PlayerData::glide_walk;
						 //action = getAction("glide_walk");
			         }
			         else if(currentBankSpeed > 0)
			         {
						 setActionThread(PlayerData::glide_walk_bank_right, true, false, true,false,true); 
						 //action = PlayerData::glide_walk_bank_right;
						 //action = getAction("glide_walk_bank_right");
			         }
		         }
		         else if(currentGlideSpeed == mDataBlock->maxGlideSpeed)
		         {
			         if(currentBankSpeed < 0)
			         {
						 setActionThread(PlayerData::glide_run_bank_left, true, false, true,false,true); 
						 //action = PlayerData::glide_run_bank_left;
						 //action = getAction("glide_run_bank_left");
			         }
			         else if(currentBankSpeed == 0)
			         {
						 setActionThread(PlayerData::glide_run, true, false, true,false,true);
						 //action = PlayerData::glide_run;
						 //action = getAction("glide_run");
			         }
			         else if(currentBankSpeed > 0)
			         {
						 setActionThread(PlayerData::glide_run_bank_right, true, false, true,false,true);
						 //action = PlayerData::glide_run_bank_right;
						 //action = getAction("glide_run_bank_right");
			         }
		         }
	         }
	         else
	         {
		            if (mContactTimer >= sContactTickTime)
	               {
		               // Nothing under our feet
			         action = PlayerData::RootAnim;
	               }
             }
      }
//--------------------------------End Edit---------------------------
#20
03/21/2010 (10:01 am)
else if ( mSwimming )
   {
      action = PlayerData::SwimRootAnim;

      F32 curMax = 0.1f;
      VectorF vel;
      mWorldToObj.mulV(mVelocity,&vel);
      for (U32 i = PlayerData::SwimForwardAnim; i <= PlayerData::SwimRightAnim; i++)
      {
         PlayerData::ActionAnimation &anim = mDataBlock->actionList[i];
         if (anim.sequence != -1 && anim.speed) 
         {
            // Bias towards picking the forward/backward anims over
            // the side to prevent oscillation between anims.  This seems to work
            // ok but the real fix is to have 8 way directional animations.
            VectorF biasedDir = anim.dir * VectorF(0.5f,1.0f,0.5f);
            F32 d = mDot(vel, biasedDir);
            if (d > curMax)
            {
               curMax = d;
               action = i;
               forward = true;
            }
         }
      }
   }
   else if ( mPose == StandPose )
   {
      if (mContactTimer >= sContactTickTime) {
         // Nothing under our feet
         action = PlayerData::RootAnim;
      }
      else
      {
         // Our feet are on something
         // Pick animation that is the best fit for our current velocity.
         // Assumes that root is the first animation in the list.
         F32 curMax = 0.1f;
         VectorF vel;
         mWorldToObj.mulV(mVelocity,&vel);
         for (U32 i = 1; i < PlayerData::NumMoveActionAnims; i++)
         {
            PlayerData::ActionAnimation &anim = mDataBlock->actionList[i];
            if (anim.sequence != -1 && anim.speed) 
            {
               // We bias towards picking the forward/backward anims over
               // the side to prevent oscillation between anims.  This seems 
               // to work ok but the real fix is to have 8 way directional 
               // animations.
               VectorF biasedDir = anim.dir * VectorF(0.5f,1.0f,0.5f);
               F32 d = mDot(vel, biasedDir);
               if (d > curMax)
               {
                  curMax = d;
                  action = i;
                  forward = true;
               }
               else
               {
                  // Special case, re-use slide left animation to slide right
                  if (i == PlayerData::SideLeftAnim && -d > curMax)
                  {
                     curMax = -d;
                     action = i;
                     forward = false;
                  }
               }
            }
         }
      }
   }
   else if ( mPose == CrouchPose )
   {
      VectorF vel;
      mWorldToObj.mulV(mVelocity,&vel);
      
      action = PlayerData::CrouchRootAnim;
      fsp = true;

      if ( vel.y > 0.1f )
      {
         action = PlayerData::CrouchForwardAnim;
         forward = true;
      }
      else if ( vel.y < -0.1f )
      {
         action = PlayerData::CrouchForwardAnim;
         forward = false;
      }            
   }
   else if ( mPose == PronePose )
   {
      VectorF vel;
      mWorldToObj.mulV(mVelocity,&vel);

      action = PlayerData::ProneRootAnim;
      fsp = true;

      if ( vel.y > 0.1f )
      {
         action = PlayerData::ProneForwardAnim;
         forward = true;
      }
      else if ( vel.y < -0.1f )
      {
         action = PlayerData::ProneForwardAnim;
         forward = false;
      } 
   }
   setActionThread(action,forward,false,false,fsp);

}

void Player::onImageRecoil(U32,ShapeBaseImageData::StateData::RecoilState)
{
   if (mRecoilThread)
   {
      mShapeInstance->setPos(mRecoilThread,0);
      mShapeInstance->setTimeScale(mRecoilThread,1);
   }
}

Page «Previous 1 2 3 Last »