diff --git a/Assets/Scripts/GameMode.cs b/Assets/Scripts/GameMode.cs index 09496fc..b07972f 100644 --- a/Assets/Scripts/GameMode.cs +++ b/Assets/Scripts/GameMode.cs @@ -40,6 +40,17 @@ public void StartGame() } isGameRunning = true; + if (player) + { + player.gameObject.SetActive(false); + GameObject.Destroy(player.gameObject); + } + if (player2) + { + player2.gameObject.SetActive(false); + GameObject.Destroy(player2.gameObject); + } + // 生成人物 playerStart1 = GameObject.Find("PlayerStart1"); if (playerStart1 != null ) @@ -96,11 +107,8 @@ public void StopGame() // 控制 UI Panel uiController.EnterEndPanel(); - - player.gameObject.SetActive(false); - GameObject.Destroy(player.gameObject); - player2.gameObject.SetActive(false); - GameObject.Destroy(player2.gameObject); + player.disableInput(); + player2.disableInput(); } public void EndGame() diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index d1eeac3..2d7bc59 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -49,9 +49,18 @@ void endGame() { GameObject.Find("GameMode").GetComponent().StopGame(); } + private bool disableUserInput = false; + public void disableInput() + { + disableUserInput = true; + } void Update() { + if (disableUserInput) + { + return; + } //GROUNDED if (Physics.Raycast(transform.position + new Vector3(0.1f, 0.1f, 0.1f), Vector3.down, 0.15f) || Physics.Raycast(transform.position + new Vector3(0.1f, 0.1f, -0.1f), Vector3.down, 0.15f)