Saving and Reloading Animation States

This is an odd problem which I cannot for the life of me solve.
I have been learning coding for the past 5 years, I am able to solve over 99% of the problems I come across now, yet this one is seemingly impossible, yet it’s definitely not. This is the most deceptively simple thing I’ve ever tried.
The task:
For R6, create a system in the roblox Animate script which can:

  1. Save an animation state
  2. Load an animation state
  3. Continue playing the animation state from where it left off
  4. No animation bugs (i.e. having extra things playing causing a “half animation”)
  5. Preferably NOT choppy
    Using the Animate script which is generated by Roblox and is put in the character.
    One of my attempts, it records your movement for a few moments before telling you it’s about to replay in 5 seconds:
    Animate.rbxm (10.8 KB)
    Preferably, do not clear animations within the load function, to ensure it’s not choppy.
    To test it properly, I recommend jumping every few moments before it tells you it’s complete and going to replay.
    Good luck because this is hard.
1 Like

Ran across a module a while back that can rewind time. Pretty cool, maybe something in that can help you out here. TimeModule - Reverse. It’s super touchy and you’ll have to work with it a bit, but it actually can do a full real-time rewind.

1 Like

While it may appear that it “works” the issue is, you unfortunately cannot stop a rewind and then play it forward, with a correct animation. Let’s say hypothetically, you do some stuff, rewind, and then play it forward, and then use an editor to cut the rewinded things out.
You would see a jump in animation and that looks bad for what I am trying to do.
I know this module wouldn’t work right when I saw it was only saving the CFrames of things, and not doing anything with the Animate script.
Thank you though!

Can you explain more on why that doesnt work

If you make an “animation” by recording a bunch of weird stuff, rewind, play it forward, then cut out the rewinded part, then the animation is now just the forward part that was originally recorded

Also what do you mean by jump in animation

1 Like

It’s hard to explain it, but I’ll record it for you.


The best way I can explain it is that the animation seems to teleport in time, it looks bad for what I’m trying to do. The moment I un-rewind, the animation teleports.

Well it is a bit raw as is… You’ll have to touch it up to get it to work. Just something I ran across, may or may not be helpful. gl

1 Like

thank you, but as i’ve said, this problem is deceptively simple. The hardest thing to do is #3, continuing the animation where it left off. Why it is “impossible” is a mystery to me, even though it certainly is NOT impossible.

I’m pretty sure you have to modify the roblox Animate script in order to have a solution, which is FINE, but even then it’s still extremely difficult to do.

its because time in rewind is linearly decreasing, and then suddenly linearly increasing with no interpolation between the derivatives

when the rewind is almost done it should slow the framerate down, then switch to un-rewind at the slowest point, and then speed back up

I have no idea what that means, could you please make me a demonstration?
:smiley:

assuming you have the animation stored as a series of cframes

--pseudocode

-- corresponds to which set of cframes the animation is on, 100 is the last cframe
local frameIndex = 100 
local reversing = true -- start as reversing in this scenario

--this many loops are required to go to next frame
local waitInterval = 1

[runservice loop]:Connect(function()

  waitInterval -= 1
  if waitInterval ~= 0 then return end

  --probably better to do this with an equation instead for more smoothness

  if frameIndex < 3 then
    waitInterval = 5 -- 1/5 speed
  elseif frameIndex < 15 then
    waitInterval = 3 -- 1/3 speed
  else
    waitInterval = 1 -- 100% speed
  end
  
  if reversing then
    frameIndex -= 1
  else
    frameIndex += 1
  end

  if frameIndex == 0 then reversing = true end
  
  --move the character and world based on the frame
  updateAnimation(frameIndex)

  
end)

show me a video of this in action

heres a simple animation to demonstrate

with linear, the character jumps from going backwards to forwards instantly which looks akward

when you add some kind of function that transforms time (quad inout easing in this case), the character smoothly stops at the point where they change directions and then slowly speeds back up in the other way

That is not what I am looking for unfortunately.
I am essentially looking for a way to save the state of the Animate script and reload it when I want to, with condition #3 being satisfied as well.

yes so you would just add easing into the system you already have

1 Like

Waiiit I think I get what you’re saying now. However, I do not think that it would be entirely accurate to the actual roblox animation system, and I also think I see an issue with it, the character cframe would be paused

I had an idea and it worked!
Thank you to everyone who tried to help me on this, but I have found a solution. Here is the solution:
AnimateComplete.rbxm (13.3 KB)
However, there is a MINOR bug with the system, where the animation teleports due to it having to reset for the new timestamp, but it won’t be an issue with what I am implementing it into.
Have a good day! :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.