I have a self contained physics simulation (eg fragments of a building crumbling) which is known to be the same, excepting floating point precision errors, every time it is run.

Is there a way to improve performance by pre-calculating/recording the simulation?

It would seem that the build in physics engine does not support this, but are there other engines that do?

Or alternatively, would recording the transformation of each Rigidbody in the simulation, and then playing back those transforms, be a sensible approach to increase performance? It would remove a lot of Rigidbodies, joints and enable flattening the hierarchy.

  • \$\begingroup\$ Are you looking for something like animating the behaviour instead of calculating it? \$\endgroup\$ Commented Feb 28, 2019 at 16:07
  • \$\begingroup\$ I've successfully recorded transform positions/rotations and played them back. Did you run into any trouble implementing and profiling a test of this approach, to check whether it's beneficial to your case? \$\endgroup\$
    – DMGregory
    Commented Feb 28, 2019 at 16:24

2 Answers 2


Use GameObjectRecorder:

Records the changing properties of a GameObject as the Scene runs and saves the information into an AnimationClip.

This class binds GameObject properties, records their values as they change in the running Scene, and saves the result in an AnimationClip. The recorded GameObject is called root in the class, and you can also bind the properties of any child of root.

Here's the thread on the Unity forums explaining its use when it was originally being designed


Alternatively, you could try the Unity Recorder asset, which is built on top of GameObjectRecorder, and provides a GUI interface, but is quite a bit more complex.

The Unity Recorder is an Editor-only tool that captures video and animation data during gameplay. It records to various media formats. It is compatible with Unity 2018.1 and up.

It can be used to record to video clips, image sequences, or to an animation clip, the last one being the one you'd want to use. I don't have experience with this asset though, so I don't know whether it will actually do what you are looking for.


Since you state that all runs are the same, I think the ideal solution here would be to treat the whole thing as a single object and animation.

To my knowledge, Unity does not have a built-in animation-baking feature, unlike it's main competitor Unreal and several other engines. However, nothing prevents you from baking the animation in an external program like Blender and importing and using it in Unity.

If you need the objects to be able to become dynamic, however, it might then be better to have a script that records the positions and rotations of rigidbodies into a file, in order to have a persistent baked copy of the animations, and then use another script on each fragment to play back that fragment's animation when needed. This allows for each object to be separate and contain a rigidbody that can be switched to it's dynamic behaviour when an external interaction like a collision is detected.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .