I’m wondering if I could start my game from a point in time after the physics engine has moved my game objects a bit.
I have many blocks that roll down a hill, and I want the game to start when the blocks are at the bottom of the hill, so the player doesn’t have to watch them actually roll. I think I have to write down the position/rotations of all the blocks, and then manually move them there after stopping the play test. This can get quite tedious with many blocks. Is there a better way to do this?
It’s basically saving the scene as it is after the physics engine has done its part moving the objects.
Using physics to place stuff is a feature sadly missing from Unity. I had such a feature in HeroEngine because it was so useful.
However there are tools in the Asset Store that let you maintain stuff that happens during play. For example, Editor++ comes to mind. Using that plugin you can then select all the cubes and have it remember their transform during play. Then stop and apply what was remembered and they’ll be in their settled (at the bottom of the hill) location.
This is far easier than doing it manually with pencil and paper. But if you don’t want to use a 3rd party component like that, you could write a script that on some input (say a button press) records all the important transform info from the objects you are interested in to a file. If you give them a unique name, then it would also be straightforward to read that file back in with yet another script (editmode this time) and apply the updated transforms back to said objects.