lennonr

As the title says, is it possible to play animations in stepped mode within Unity?

Thanks in advance!
lennonr
Posts: 2

Harald

Yes, it is! One way this can be achieved can be found here:
Changing refresh rate at runtime to mimic No Interpolation
User avatar
Harald

Harri
Posts: 147

lennonr

Cheers for the snippet, it’s helpful in getting us to our desired effect.

Is it possible to playback only keyframes in Unity? This would be very useful for my team as well.

Thanks again!
lennonr
Posts: 2

Harald

You could access the frame times but there is a more coding involved - you can take the SkeletonBaker.cs, ParseRotateTimeline() method as a reference:

You need to access all timelines of an animation as in line 782 in SkeletonBaker.cs:

spine-runtimes/SkeletonBaker.cs at 3.7

Note that you would want to parse at least the rotate timelines (of all bones), you could leave out translation, scaling, etc. The animation would be the SkeletonAnimation's currently playing animation in your case. Then at each timeline (note: there is one timeline per bone), you can query the keyframe timepoints as follows (in line 1170):

spine-runtimes/SkeletonBaker.cs at 3.7
Note that in the timeline.Frames array every even float array entry contains the timepoint and every odd entry the corresponding rotation value, so you may want to increment by index += 2 to access only keyframe timepoints:
float time = frames[f];
rotation = frames[f + 1] + boneData.Rotation;
Then you would need to add all keyframe timepoints to a sorted list and you're done.

However it will be much easier to tell your animators to move the keyframe timepoints to a fixed interval that you agreed upon, then you can save all the work above.
User avatar
Harald

Harri
Posts: 147


Return to Unity