Play an animation ONCE with directX

Started by
3 comments, last by Buckeye 13 years, 5 months ago
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?
EnJOJ Gaming
Advertisement
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?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

I've checked if all of the functions succeeds and they do. I've manually set the time of KeyTrackEnable and it didn't work. It seems the animation starts playing at random keyframe. Same thing with other animations
EnJOJ Gaming
SOLVED :D

I used the SetTrackPosition() and set it to Zero and it works perfectly!
But if someone knows why this happend then please give a explanation :)
EnJOJ Gaming
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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement