- Home /
Saving jump power/Pause controller
Hello, I've a little problem with getting back jump power after pausing game. I don't want to use Time.timescale for pausing my game so I'm setting my Player object to kinematic and setting his speed.x to 0 to prevent him from moving vertically. I want to continue on jumping when I pause game instead of starting to falling e.g. when I jump but I don't reach maximum point of my jump and I stop my game - after resume I'm falling down instead of ending my jump. Here is the code:
protected override void OnPause()
{
rigidbody2d.isKinematic = true;
speed.x = 0;
PauseText.SetActive(true);
}
protected override void OnResume()
{
rigidbody2d.isKinematic = false;
speed.x = 5;
PauseText.SetActive(false);
}
Comment
Best Answer
Answer by cncjourneyman · Nov 17, 2015 at 12:57 PM
you just need to save a new variable as the rest of the potential jump, then after the unpause you refer to that variable to get you back where you left off