Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

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:
    45
    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:
    45
    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).
     
unityunity