• Editor
  • [Unity] Obtaining A Specific Timestamp In An Animation

Good Evening,

When I import Spine animations into Unity I can view an Animation Reference Asset's total duration in the inspector:

But I don't know how to scrub through an animation to get a specific time that something happens.
For example, if I have an animation of a character clapping five times, and I want to know the point in the animation where the third clap happens, is there a simple way to obtain the timestamp?

Thanks!

    Related Discussions
    ...

    PayasoPrince Why not add an event key to the clapping animation?: https://esotericsoftware.com/spine-events#Events
    To handle the event, you can add a delegate. An example code for this can be found here: https://esotericsoftware.com/spine-unity#Processing-AnimationState-Events
    Then, you can check the time when the event was fired by using the animationTime method of TrackEntry. However, if your goal is to synchronize something to the timing of the third clap, simply adding a delegate to the user-defined event might be sufficient.

      Misaki Thanks for the reply, Misaki! 😊
      Moving forward I will experiment with adding event keys into Spine animations.

      Is there a way to obtain a specific time for an animation I have already imported into Unity that does not have an event key?

        PayasoPrince Hmmm, I'm afraid I don't have any good ideas. I can think of a few roundabout ways to do this (e.g. using the Timeline extension to place the animation on a SkeletonAnimation Track of the Timeline and set the Start time to show the third clap pose, then see the seconds displayed in the Inspector window), but maybe @Harald can give you a better idea.

        @PayasoPrince The best way would be to have the Spine project open, select the desired animation and scub through it. You can use Spine - Import Data .. and the Spine - Texture Unpacker if your animator does not share the Spine project with you.

        A solution purely inside Unity would be to use the Timeline window. Note that you need the Spine Timeline extension installed:
        https://esotericsoftware.com/spine-unity#Timeline-Extension-UPM-Package

        Then you can add your target animation to a timeline by dragging the AnimationReferenceAsset into a Timeline track, and then scrub in the Timeline window as usual. You can also change the display of the Timeline window from Frames to Seconds via the gear icon at the right end of the Timeline window.