• Editor
  • Baking Physics and Looping

Will it be possible to bake physics down to keys, perhaps, with an optional adaptive mode that attempts to be smart about where to place keys? Or having a simplify option for keys in general.

Also, regarding looping physics, I would also like to use physics in a loop, its amazing having dynamic physics at runtime, but another great thing about physics is the time savings it can bring. Although, I plan to use dynamic physics at runtime I would also like to create looping .gifs to share. Another reason to have looping physics might if you want to export to sprite sheets instead. In my case with sharing a gif / apng I would like to use physics instead of manually animating to save time and to make my animation more flexible should I want to change it.

I think baking to keys will allow you to do looping of physics manually with a bit of extra work.

Perhaps, it would be possible to interpolate between the start and end of the physics when looping or maybe something like this could be integrated into Spine. In order for that to work I think you would need to apply it to the whole animation though.

Related Discussions
...

We may be able to allow dropping keys manually for the physics pose in 4.2, but it is unlikely we'll have any other baking features in 4.2.

In general if your end result needs to loop, I'd say don't use physics. Baking would help, though it would require manual fix up.

When it's just showing your work rather than the final result, probably making a GIF that repeats 3-4 times before looping is sufficient. For an export that repeats some 3-4 times, with some effort you can choose start/end frames for the export that loop with a minimal jump, at least sometimes.

As you mentioned, you can key mixing the physics in/out at the start/end. I think that won't work most of the time though.

The interpolation you linked is interesting. We'll give that some thought!

@Nate So, I played around with physics and I noticed something that I remembered reading about on the forum (link to post below), physics loop while in the editor if deterministic physics are disabled. However, when exporting the loop is broken because the physics pose resets on the first frame rather than carrying through the motion. Presumably, the export uses deterministic physics. So, If its possible to implement the ability to export using non-deterministic physics, looping can be achieved if the simulation is pre-run a couple times before the export happens. Maybe it would be possible to advanced the physics, letting it loop a couple times. Then advance the physics, draw the skeleton (and other stuff that's needed) to a render target / buffer and save it and repeat until the animation is finished. If its not easy to add to the editor I think I should be able to do this using the runtime. Although, having it built into the editor would be best.

Also, See this forum post where the same behavior is described. It also seems like this post describes the same behavior.

This video is a screen capture of the editor, with non-deterministic physics running at 120 fps, which I trimmed so that video matches the length of the animation and the animation was pre-run. If you right click on the video and select loop and watch it a couple times you can tell that the physics are looping.

Here is the animation exported to a gif, as you can see it is no longer looping. If you enable deterministic physics in the editor you can see that it also does not loop in a similar / same way as the .gif.

I feel like it should also be possible to loop with deterministic physics as well. Here is a gif where I copied the animation and pasted it on the end of the animation. Also, I keyed the rotation on the start and end frames before copy pasting. I then exported it by limiting the export range to the duplicated animation and enabling include last frame in the export.

Also, this isn't related to looping but I noticed when I enable deterministic physics the end bone has a weird rotation on the start frame.

Also, sorry this is also not related but I was wondering when the spine-c and spice-c++ runtimes would be updated for 4.2. Not expecting a exact time frame I was just wondering how far down in the list they are compared to other runtimes.

5 days later

Here is another example of someone seeing the looping working in the editor but not at export. Additionally, a reply in the post by Erika shows a potential workaround that is similar to one of the things I tried above.

  • Nate replied to this.

    Sorry I wanted to respond when I had a better update, but things have been busy.

    It's possible to "warm up" the physics by Spine playing the animation for some time behind the scenes, then doing the export. This is essentially what Erika's steps do. We could have export settings to do that, but it isn't perfect.

    There is no guarantee this will result in looping. There are physics settings that never settle or otherwise will not loop. For example, apply gravity or wind with strength 0. Other settings can create oscillation that doesn't repeat or repeats over an extremely long period or a period that doesn't match up to the animations.

    In the cases where the physics does appear to loop, there is no guarantee that the start frame and end frame are the same. They are often similar, but the movement for subsequent iterations can be off be a small amount. This can cause a jump at the loop point, the severity of which can vary and is not controllable since it comes from repeatedly applying the physics math.

    Still, in some cases it would result in a looping animation with physics, which is better than not having it for those cases. We'll give it a shot, but only after we've finished folders for constraints (and draw order, probably).

    3 months later