Skip to content

Commit

Permalink
Merge pull request #203 from SCCapstone/spencer-dev
Browse files Browse the repository at this point in the history
Gravity resets when restarting a level from the pause menu. Fixes #176.
  • Loading branch information
stbeaumont98 authored Apr 14, 2024
2 parents a72b615 + 7744e9a commit a0f2b38
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 a0f2b38

Please sign in to comment.