How can I play an animation only once?
Hi,
I've made two animations.One is called "walk",and the other is "jump",they are in the same .X file. Frame 94-124:walk, Frame 178-203:jump.
Here is the problem i've got.I want my hero(in my game) to jump when I press the
space key,and need it to jump only once,then translate to "walk" automatically.
I've been thinking about using the ID3DXAnimationCallbackHandler interface.I set a key at the end of the "jump" animation to notice my ID3DXAnimationController to chang the animationset to "walk".But I still have the "walk" animation to deal with, and it needs two keys to play the step sound at proper time. So,I guess it's
not the best way to do this,since it costs to change the keys frequently. The most import thing is that it looks like too inconvenient.I gess there should be a more effiect and direct way.
Then I found ID3DXAnimationController::GetTime() method in SDK,which is used to gets "the global animation time". Is this used to get the current time of the whole animation's duration?If yes, how can i get the duration of "jump".If I get both the current time and the whole duration,I can figure out the percent of the animation being played,when which reach to 100%,I can chang the animationset to "walk".
So,is there anyone familiar with animation controlling.Help me please!
IMO, you'll be better off if you split the two animations into their own animation sets instead of having them be two portions of the same animation.
That way you don't have to rely on weird magic number effects in order to play one animation, or the other.
That way you don't have to rely on weird magic number effects in order to play one animation, or the other.
Thanks for your advice!
But I don't quite catch you.Would you please tell me how to
divide one animation into two?
Actually ,I guess I have divided them. The .X file was
exported by Panda plugin for 3ds max9. And the two animations are in different frame sections,"walk" 94-124,and "jump" 178-203.
In my codes I switch between them like this:
LPD3DXANIMATIONSET pAnimationSet;
if(m_PlayerList.m_Action == csChar::ACTION::walk)
{
if(FAILED(m_animCtrl->GetAnimationSetByName("walk",&pAnimationSet))) return E_FAIL;
}
else
{
if(FAILED(m_animCtrl->GetAnimationSetByName("jump",&pAnimationSet))) return E_FAIL;
}
if(FAILED(m_animCtrl->SetTrackAnimationSet(0,pAnimationSet))) return E_FAIL;
And the most concerned question is that how to know that the "jump" animation is
played for only once?Is there a method to get the progress of the animation?
Thanks again!
ps:How to post my codes in a single text controller?:)
But I don't quite catch you.Would you please tell me how to
divide one animation into two?
Actually ,I guess I have divided them. The .X file was
exported by Panda plugin for 3ds max9. And the two animations are in different frame sections,"walk" 94-124,and "jump" 178-203.
In my codes I switch between them like this:
LPD3DXANIMATIONSET pAnimationSet;
if(m_PlayerList.m_Action == csChar::ACTION::walk)
{
if(FAILED(m_animCtrl->GetAnimationSetByName("walk",&pAnimationSet))) return E_FAIL;
}
else
{
if(FAILED(m_animCtrl->GetAnimationSetByName("jump",&pAnimationSet))) return E_FAIL;
}
if(FAILED(m_animCtrl->SetTrackAnimationSet(0,pAnimationSet))) return E_FAIL;
And the most concerned question is that how to know that the "jump" animation is
played for only once?Is there a method to get the progress of the animation?
Thanks again!
ps:How to post my codes in a single text controller?:)
same as legalize, I also suggest you to sprite animation in to 2
the meaning is
.X file can contain more than 1 animation set on each object
so your hero can contain 2 animation
1. is jump start from frame 1 to N
2. is walk start from frame 1 to N
and more and more animation
I'm not sure how to set DDX to play each animation set (I'm using OpenGL). but I quite sure that DDX can (because .X is dedicate for DDX)
Chet Chetchaiyan
the meaning is
.X file can contain more than 1 animation set on each object
so your hero can contain 2 animation
1. is jump start from frame 1 to N
2. is walk start from frame 1 to N
and more and more animation
I'm not sure how to set DDX to play each animation set (I'm using OpenGL). but I quite sure that DDX can (because .X is dedicate for DDX)
Chet Chetchaiyan
Quote:Original post by bloodmagic
ps:How to post my codes in a single text controller?:)
Use the 'source' markup tag in your post.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement