Implement LocalPlayer.DisableInput
This commit is contained in:
parent
60b109a629
commit
2fb6d279da
@ -25,18 +25,15 @@ namespace NeonTea.Quakeball.Player {
|
|||||||
|
|
||||||
CrouchAction = new InputAction("crouch", binding: "<Gamepad>/buttonEast");
|
CrouchAction = new InputAction("crouch", binding: "<Gamepad>/buttonEast");
|
||||||
CrouchAction.AddBinding("<Keyboard>/leftShift");
|
CrouchAction.AddBinding("<Keyboard>/leftShift");
|
||||||
CrouchAction.Enable();
|
|
||||||
|
|
||||||
JumpAction = new InputAction("crouch", binding: "<Gamepad>/buttonSouth");
|
JumpAction = new InputAction("crouch", binding: "<Gamepad>/buttonSouth");
|
||||||
JumpAction.AddBinding("<Keyboard>/space");
|
JumpAction.AddBinding("<Keyboard>/space");
|
||||||
JumpAction.performed += _ => {
|
JumpAction.performed += _ => {
|
||||||
WantsToJump = true;
|
WantsToJump = true;
|
||||||
};
|
};
|
||||||
JumpAction.Enable();
|
|
||||||
|
|
||||||
LookAction = new InputAction("look", binding: "<Gamepad>/leftStick");
|
LookAction = new InputAction("look", binding: "<Gamepad>/leftStick");
|
||||||
LookAction.AddBinding("<Mouse>/delta");
|
LookAction.AddBinding("<Mouse>/delta");
|
||||||
LookAction.Enable();
|
|
||||||
|
|
||||||
MoveAction = new InputAction("move", binding: "<Gamepad>/rightStick");
|
MoveAction = new InputAction("move", binding: "<Gamepad>/rightStick");
|
||||||
MoveAction.AddCompositeBinding("Dpad")
|
MoveAction.AddCompositeBinding("Dpad")
|
||||||
@ -44,15 +41,25 @@ namespace NeonTea.Quakeball.Player {
|
|||||||
.With("Down", "<Keyboard>/s")
|
.With("Down", "<Keyboard>/s")
|
||||||
.With("Left", "<Keyboard>/a")
|
.With("Left", "<Keyboard>/a")
|
||||||
.With("Right", "<Keyboard>/d");
|
.With("Right", "<Keyboard>/d");
|
||||||
MoveAction.Enable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start() {
|
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.visible = false;
|
||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update() {
|
|
||||||
OptionsData Opts = Options.Get();
|
OptionsData Opts = Options.Get();
|
||||||
|
|
||||||
Vector2 LookInput = LookAction.ReadValue<Vector2>() * Opts.LookSensitivity;
|
Vector2 LookInput = LookAction.ReadValue<Vector2>() * Opts.LookSensitivity;
|
||||||
|
Loading…
Reference in New Issue
Block a user