Jump to content

one shot animation


cassius
 Share

Recommended Posts

I am struggling to get a "dieing" animation to work just once despite watching aggrors tutorial many times. If anyones got a short example in c++ I would be much obleeged.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

There is some example in player.lua

At the end of attack it calls another function, it's some callback if im' not wrong.

In fact if you use AnimationManager, you put all parameters and last one is a function name to call at the end of animation.

 

You can also manage that yourself if you can get what frame is playing.

Stop toying and make games

Link to comment
Share on other sites

 

This code works, but a bit too fast.

 

 

void kill_badguy()

{

if(badguy_frame < badguy_length){

 

badguy->SetAnimationFrame(badguy_frame,1,badguyseq);

 

badguy_frame++;

}

if(badguy_frame >= badguy_length)

badguy_alive = false;

}

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Hi Cassius

 

Here is something Ive adapted from the lua code...

 


void GameCharacter::SetAnimationSequence(float blendTime)
{
blendStart = Time::GetCurrent();

blendFinish = blendStart + blendTime;
}


 

 

 


if(characterState != prevCharacterState)
{
SetAnimationSequence(500); //This only gets hit once.
}

sequence = 1; // or whatever

float animSpeed = 0.04F;
float blend = (Time::GetCurrent() - blendStart) / (blendFinish - blendStart);

blend = Math::Min(1.0, blend);
frame = (Time::GetCurrent() - blendStart) * animSpeed;

float length = entity->GetAnimationLength(sequence, true);

if(frame >= (length - 1))
{
frame = length -1;

characterState = kStateIdle;
}

entity->SetAnimationFrame(frame, blend, sequence, true);

 

Hope this helps

trindieprod.png?dl=0spacer.png?dl=0steam-icon.png?dl=0twitter-icon.png?dl=0spacer.png?dl=0
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...