From 399c6f1a70eb07b5734a83df5413692aba151a68 Mon Sep 17 00:00:00 2001 From: moshuying <1460083332@qq.com> Date: Sun, 7 Jul 2024 10:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=93=E6=9D=9F=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E4=BA=BA=E7=89=A9=E7=9E=AC=E9=97=B4=E6=B6=88=E5=A4=B1?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=BC=80=E5=A7=8B=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=A4=9A=E4=B8=AA=E7=8E=A9=E5=AE=B6=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/GameMode.cs | 18 +++++++++++++----- Assets/Scripts/PlayerController.cs | 9 +++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) 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)