Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Skip to next frame in animation on button press

Discussion in 'Scripting' started by sevenxfdesign, Sep 15, 2022.

  1. sevenxfdesign

    sevenxfdesign

    Joined:
    Sep 15, 2022
    Posts:
    1
    Hi, I am developing a set of physics simulations in Unity for which I have animated models of various physics IGCSE concepts, such as DC motor.

    I have an animation of the coil rotating around the magnet with a pause and play button.

    I am trying to add a button that will skip to the next frame of the animation or +10 frames while paused. I am using the animator for the animation, is there any way to achieve this in Unity 2022?

     
  2. Zalosath

    Zalosath

    Joined:
    Sep 13, 2014
    Posts:
    687
    How about something like this.

    It's not using frames per se as I'm not 100% sure you can even do that with Unity, but it does use the time, which can be used to specify a specific time that a frame will have played.

    If you know the framerate of the animation and its total length, you can use those to calculate the time a desired frame will be played.