cassius Posted August 12, 2013 Share Posted August 12, 2013 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. Quote 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 More sharing options...
YouGroove Posted August 12, 2013 Share Posted August 12, 2013 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. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
cassius Posted August 12, 2013 Author Share Posted August 12, 2013 Thanks yougroove I will take a look. . I want to stick to c++. coding if possible, I have "walk" and other animations working fine. Quote 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 More sharing options...
cassius Posted August 12, 2013 Author Share Posted August 12, 2013 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; } Quote 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 More sharing options...
tjheldna Posted August 12, 2013 Share Posted August 12, 2013 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 Quote Link to comment Share on other sites More sharing options...
cassius Posted August 13, 2013 Author Share Posted August 13, 2013 Thanks for that code. That goes into my usefull snippets folder.I slowed down my animation by decreasing badguy_frame by 0.5 instead of 1. Quote 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 More sharing options...
Recommended Posts
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.