Skip to content

Commit

Permalink
Gravity resets when restarting a level from the pause menu. Fixes #176.
Browse files Browse the repository at this point in the history
  • Loading branch information
stbeaumont98 committed Apr 14, 2024
1 parent 6455c3d commit 7744e9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 352 deletions.
3 changes: 3 additions & 0 deletions Assets/Scripts/Pause Menu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ public class PauseMenu : MonoBehaviour
public GameObject pauseMenu;
public GameObject controlsMenu;
public GameObject optionsMenu;
public Vector2 startGravity;
// Start is called before the first frame update
void Start()
{
startGravity = Physics2D.gravity;
pauseMenu.SetActive(false);
controlsMenu.SetActive(false);
optionsMenu.SetActive(false);
Expand All @@ -33,6 +35,7 @@ public void menu()
}

public void Restart() {
Physics2D.gravity = startGravity;
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/PlayerHealth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public IEnumerator PlayerRespawn()
yield return new WaitForSeconds(2);
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
pm.enabled = true;
Physics2D.gravity = new Vector2(startGravity.x, startGravity.y);
Physics2D.gravity = startGravity;
SceneTransition.SetBool("isDead", false);
}

Expand Down
Loading

0 comments on commit 7744e9a

Please sign in to comment.