From 2fb6d279dacf3f453c5484587f8e8d7d062e5bfd Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Fri, 7 Aug 2020 00:42:39 +0300 Subject: [PATCH] Implement LocalPlayer.DisableInput --- Assets/Scripts/Player/LocalPlayer.cs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Player/LocalPlayer.cs b/Assets/Scripts/Player/LocalPlayer.cs index 5b75fce..1913b8b 100644 --- a/Assets/Scripts/Player/LocalPlayer.cs +++ b/Assets/Scripts/Player/LocalPlayer.cs @@ -25,18 +25,15 @@ namespace NeonTea.Quakeball.Player { CrouchAction = new InputAction("crouch", binding: "/buttonEast"); CrouchAction.AddBinding("/leftShift"); - CrouchAction.Enable(); JumpAction = new InputAction("crouch", binding: "/buttonSouth"); JumpAction.AddBinding("/space"); JumpAction.performed += _ => { WantsToJump = true; }; - JumpAction.Enable(); LookAction = new InputAction("look", binding: "/leftStick"); LookAction.AddBinding("/delta"); - LookAction.Enable(); MoveAction = new InputAction("move", binding: "/rightStick"); MoveAction.AddCompositeBinding("Dpad") @@ -44,15 +41,25 @@ namespace NeonTea.Quakeball.Player { .With("Down", "/s") .With("Left", "/a") .With("Right", "/d"); - MoveAction.Enable(); - } - - private void Start() { - Cursor.visible = false; - Cursor.lockState = CursorLockMode.Locked; } private void Update() { + if (DisableInput) { + CrouchAction.Disable(); + JumpAction.Disable(); + LookAction.Disable(); + MoveAction.Disable(); + Cursor.lockState = CursorLockMode.None; + Cursor.visible = true; + } else { + CrouchAction.Enable(); + JumpAction.Enable(); + LookAction.Enable(); + MoveAction.Enable(); + Cursor.visible = false; + Cursor.lockState = CursorLockMode.Locked; + } + OptionsData Opts = Options.Get(); Vector2 LookInput = LookAction.ReadValue() * Opts.LookSensitivity;