How to pause and resume UIDynamicAnimator physics simulation

527 views Asked by At

How would you go about pausing and resuming a UIDynamicAnimator's physics simulation? There is no way to programmatically pause and resume. There is a "paused" state when all items are at rest however I am am looking for something different. For example, I'd like to have an item being pulled by a gravity field, then press a pause button to pause the simulation, and then press a resume button and have the simulation resumed as if nothing happened. The item maintains it's trajectory, velocity, etc.

My hunch is that I have to somehow save the item's physics properties, remove the dynamic behaviors, and then add the dynamic behaviors back to mimic the saved physics properties from before. Is this the right approach?

1

There are 1 answers

0
iGenio On

You can do this only by removing all behaviours using removeAllBehaviors(). To restart the simulation you have to add each behavior