- Home /
save 2D gameobject movement - for pause resume
I found script to save the movement(velocity) of a 3D object for pause. But I cant apply it to 2D object. I want to use this for pause menu but I dont want to set timescale to 0. The script I found was:( I am a newbie, help please:))
void OnPauseGame()
{
savedVelocity = rb.velocity;
savedAngularVelocity = rb.angularVelocity;
rb.isKinematic = true;
}
void OnResumeGame()
{
rb.isKinematic = false;
rb.AddForce(savedVelocity, ForceMode2D.Force);
rb.AddTorque(savedAngularVelocity, ForceMode2D.Force);
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612203428im_/https://answers.unity.com/themes/thub/images/avi.jpg)