Sign in to follow this  
Johannes1991

Play an animation ONCE with directX

Recommended Posts

Here's the problem! I'm using a animated mesh with directx functions and stuff. I can play different animations over and over again but i haven't figured out how to just play an animations for just one time.

I've tried this:

LPD3DXANIMATIONSET temp = NULL;
if(AniController->GetAnimationSetByName(AnimationName, &temp) != S_OK)
return;

AniController->SetTrackAnimationSet(Track, temp);

AniController->SetTrackEnable(Track, true);
AniController->SetTrackSpeed(Track, 1.0f);
AniController->SetTrackWeight(Track, 1.0f);

AniController->ResetTime();
AniController->KeyTrackEnable(Track, false, temp->GetPeriod());

temp->Release();


But the animation just ends after a random time. I've checked the temp->GetPeriod() value and it's the same everytime.

Am I approaching it all wrong? or Am i just doing it wrong?

Share this post


Link to post
Share on other sites
First, every DirectX function gives some indication of success or failure. You don't check for errors in any (except the first) of your AniController calls.

However, your approach looks correct.

Are you using the Debug Runtime? Does it tell you anything?

What do you mean by "random" time? Is it always a different length of time or is it consistent but appears incorrect?

In the way of debugging, have you tried setting KeyTrackEnable to other times?

Does it behave the same way for different animation sets?

Does it always stop after the same length of time, even for different animation sets?

Share this post


Link to post
Share on other sites
Quote:
I used the SetTrackPosition() and set it to Zero

Your KeyTrackEnable call stops the animation after the track time reaches the animation set period. If the track position isn't at zero when you set the new animation, it still stops at that value.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this