Search Unity

How to record a gameobject movement and then play it in reverse?

Discussion in 'Animation' started by ClaudiaKrog, Aug 19, 2020.

  1. ClaudiaKrog

    ClaudiaKrog

    Joined:
    Sep 30, 2017
    Posts:
    47
    I have some spheres that stay in the sky until gravity is enabled, when they fall down and roll around. Once gravity is enabled and they start to fall, I want to record their exact fall, so that I can play this animation back in reverse, in order to put them back in their original positions (on a button press - both reversed animation would play and gravity would be disabled).

    I have looked at the gameObject recorder, however that seems like it is only used in the editor, for creating an animation. It is possible that the user might throw something at the spheres, so I think it would be important for me to record the actual animation in game.

    What might be a good way to approach this problem? Thank you
     
  2. ClaudiaKrog

    ClaudiaKrog

    Joined:
    Sep 30, 2017
    Posts:
    47
    For anyone interested, I ended up doing this very manually. When the objects fell, I saved all positions to a list, and then reversed that list, and played that reversed list back over a slowed down for loop (using WaitForSeconds).
     
  3. cyanspark

    cyanspark

    Joined:
    Mar 12, 2022
    Posts:
    57