add pause menu

This commit is contained in:
2026-04-15 20:47:08 -05:00
parent 77625e7ad5
commit 46ec37309d
13 changed files with 5980 additions and 8102 deletions
+38 -2
View File
@@ -1,4 +1,5 @@
using System.Collections;
using Unity.VisualScripting.Antlr3.Runtime;
using UnityEngine;
using static UnityEngine.GraphicsBuffer;
@@ -18,7 +19,9 @@ public class PlayerController : MonoBehaviour
private CameraController cameraController;
private Vector3 moveDir;
private bool hasControl = true; // set this to false if we want to stop reading player inputs
private bool canUseTools = true; // set this to false if we want to stop reading player tool use
private bool isSprinting = false;
private bool paused = false;
// Mathematical plane used to catch the raycast from camera to get direction for
// looking at the mouse
@@ -39,6 +42,27 @@ void Update()
moveDir = Vector3.zero;
groundPlane.distance = -DougBody.transform.position.y;
// TODO: Move input detection somewhere else
if (Input.GetKeyDown(KeyCode.Escape))
{
if (!paused)
{
Time.timeScale = 0;
canUseTools = false;
hasControl = false;
GameManager.Instance.PauseMenu.gameObject.SetActive(true);
}
else
{
Time.timeScale = 1;
canUseTools = true;
hasControl = true;
GameManager.Instance.PauseMenu.gameObject.SetActive(false);
}
paused = !paused;
}
if (hasControl)
{
if (!tools[GameManager.Instance.PlayerManager.CurrentToolIndex].inUse)
@@ -47,7 +71,7 @@ void Update()
TryInteract();
}
ToolUseDetector();
CheckWeaponChange();
ApplyWalk();
// TODO: This is just for testing, remove or clean up if used
@@ -63,7 +87,11 @@ void Update()
}
}
CheckWeaponChange();
if (canUseTools)
{
ToolUseDetector();
}
CheckSprint();
ApplyGravity();
DoMovement();
@@ -257,6 +285,14 @@ public void SetCharacterControl(bool hasControl)
this.hasControl = hasControl;
}
/// <summary>
/// Sets the character's "canUseTools" bool. Tool use input is ignored when false
/// </summary>
public void SetCharacterCanUseTools(bool canUseTools)
{
this.canUseTools = canUseTools;
}
/// <summary>
/// Gets the character's "hasControl" bool. All input is ignored when false
/// </summary>