How do I force an animation to stop

Grab your favourite IDE and tinker with the innards of game engines

How do I force an animation to stop

Postby netserk on Mon May 21, 2007 1:18 pm

How do I force an animation to stop. At the moment my run-sequence doesn't always stop when the player stops running. Sometimes the player takes a step without moving because the run animation apparently need to finish its loop before plays the ACT_IDLE sequence.
netserk
Member
Member
 
Joined: Sun May 13, 2007 12:39 pm
Location: Aalborg, Denmark

Postby ChopperDave on Mon May 21, 2007 1:43 pm

Using SetActivity() doesn't do it?
User avatar
ChopperDave
Rockstar San Diego
 
Joined: Wed Feb 21, 2007 6:06 pm

Postby netserk on Mon May 21, 2007 3:05 pm

no - what should I do to make it work
netserk
Member
Member
 
Joined: Sun May 13, 2007 12:39 pm
Location: Aalborg, Denmark

Postby netserk on Tue May 22, 2007 7:53 am

I have this sequence in my .qc file:

Code: Select all
$sequence Run "poet_run" activity ACT_RUN 1 loop   
$sequence StopRun "poet_stop_run" activity ACT_STOP_RUN 1


These are animation of the player preparing an attack

I have added a "ACT_STOP_RUN" and "ACT_RUN" to the lists in ai_activity.h, ai_activity.cpp and activitylist.cpp. In the "enum PLAYER_ANIM" in shareddefs.h I added "PLAYER_STOP_RUN" and "PLAYER_RUN".
I should mention that the game I am working on is seen from a third person view and that the animations are for the player avatar.

In the HL2_Player.cpp I have added

Code: Select all
else if ( playerAnim == PLAYER_RUN )
{
   idealActivity = ACT_RUN;
}


and

Code: Select all
else if ( idealActivity == ACT_RUN )
{
   RestartGesture( Weapon_TranslateActivity( idealActivity ) );
          return;
}


(same for PLAYER_STOP_RUN/ACT_STOP_RUN)


I don't understand much of the last code "RestartGesture( ... )".

in gamemovement.cpp in CGameMovement::PlayerMove I have the following:

Code: Select all
if( player->GetAbsVelocity().Length2D() == 0 && runFlag)
{
   player->SetAnimation(PLAYER_STOP_RUN);
}


When the player velocity is zero the player doesn't run anymore and an animation of the player stopping to run is played.
The problem is that the run-animation doesn't stop immediately - which results in the player often taking a step on the ground even though he doesn'trun anymore. The PLAYER_STOP_RUN should be played immediately when the player stops.
netserk
Member
Member
 
Joined: Sun May 13, 2007 12:39 pm
Location: Aalborg, Denmark

Return to Programming

Who is online

Users browsing this forum: No registered users