# Rewinding animations

This topic is 4724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anyone know how to rewind an animation using AnimationController::AdvanceTime()? I know AdvanceTime doesn't take in timedelta values of 0 or negative.... thanks in advance. More precisely, I am trying to control an animation with a slider control, much like the slider bar you find in most media players... So firstly, use the animationset->GetPeriod() function to set the range of the slider... then in OnHScroll(), the event handler for the slider, I do something like this...
m_dCurrentPos = m_Slider1.GetPos();

double timedelta = m_dCurrentPos - m_dLastPos;
renderer->Update(); //update animation pose

m_dLastPos = m_dCurrentPos;

Currently, when I drag forwad the slider bar, everything seems ok, but now I want the animation to rewind if I drag the slider backwards, and I don' know how to do this. Many thanks... -fuchiefck

##### Share on other sites
I've been playing around with animations a bit the last week or so. So I may not be the most qualified to answer, but I'll try to answer the best I can, so I apologize in advance.

Now, one appraoch may be to detect when the slider is going backward by comparing the new slider position to the old one. Once you've determined it's going backward, you might be able to send in a negative timedelta value. I've never tried this before, but it's worth a try.

If that doesn't work. Try setting the position manually using AnimationController::SetTrackPosition and just have a variable to track the position of your animation. If you are using one animation, you are most likely on track 0, so send in 0 for the index of the track parameter.

I hope this helped in some way.

##### Share on other sites

Anyways I have tried the first suggestion before but as I said, the AdvanceTime function does not take in values of less or equal to zero, so yeah... doesn't work.

I have looked at the SetTrackPosition function, but I don't quite understand what its used for, could it be for blending the switch between two animations? I tried using it by passing in some values but nothing seems to happen yet. Anyway it could be my solution, I will look deeper into it... if any luck I will post my solution here. and thanks for your suggestions again.

-fuchiefck

##### Share on other sites
LilTrooper you're a genius! All I did was:

m_dCurrentPos = m_Slider1.GetPos();double timedelta = m_dCurrentPos - m_dLastPos;renderer->SetAdvanceTime(abs(timedelta)); //abs'ed the timedelta ///CHANGEDrenderer->GetAnimationController()->SetTrackPosition(0, m_dCurrentPos); ///ADDEDrenderer->Update(); //update animation posem_dLastPos = m_dCurrentPos;

Now I can drag the slider back and forth... hours of fun...

rating++ for you my man!

-fuchiefck

• 10
• 18
• 14
• 18
• 15