From 795c815ae21c1a13dd12feb213c5dc31171373fc Mon Sep 17 00:00:00 2001 From: EntranceJew Date: Wed, 28 Jun 2017 18:40:53 -0400 Subject: [PATCH] Made the example PlayerInputController enable or disable camera axis input as well as the names of the controls for greater compatibility out of the box. --- .../Scripts/PlayerInputController.cs | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Assets/SuperCharacterController/Scripts/PlayerInputController.cs b/Assets/SuperCharacterController/Scripts/PlayerInputController.cs index a11d5f1..172da16 100644 --- a/Assets/SuperCharacterController/Scripts/PlayerInputController.cs +++ b/Assets/SuperCharacterController/Scripts/PlayerInputController.cs @@ -4,6 +4,16 @@ public class PlayerInputController : MonoBehaviour { public PlayerInput Current; + public string jumpButton = "Jump"; + public string moveAxisX = "Horizontal"; + public string moveAxisY = "Vertical"; + public bool useMouseLook = true; + public string mouseInputAxisX = "Mouse X"; + public string mouseInputAxisY = "Mouse Y"; + public bool useRightStickInput = true; + public string rightStickInputAxisX = "RightH"; + public string rightStickInputAxisY = "RightV"; + public Vector2 RightStickMultiplier = new Vector2(3, -1.5f); // Use this for initialization @@ -17,17 +27,25 @@ void Update () { // Retrieve our current WASD or Arrow Key input // Using GetAxisRaw removes any kind of gravity or filtering being applied to the input // Ensuring that we are getting either -1, 0 or 1 - Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); + Vector3 moveInput = new Vector3(Input.GetAxisRaw( moveAxisX ), 0, Input.GetAxisRaw( moveAxisY )); - Vector2 mouseInput = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y")); + Vector2 mouseInput = Vector2.zero; + if( useMouseLook ) { + mouseInput = new Vector2(Input.GetAxis( mouseInputAxisX ), Input.GetAxis( mouseInputAxisY )); + } + - Vector2 rightStickInput = new Vector2(Input.GetAxisRaw("RightH"), Input.GetAxisRaw("RightV")); + Vector2 rightStickInput = Vector2.zero; + if( useRightStickInput ) { + rightStickInput = new Vector2(Input.GetAxisRaw( rightStickInputAxisX ), Input.GetAxisRaw( rightStickInputAxisY )); + } + // pass rightStick values in place of mouse when non-zero mouseInput.x = rightStickInput.x != 0 ? rightStickInput.x * RightStickMultiplier.x : mouseInput.x; mouseInput.y = rightStickInput.y != 0 ? rightStickInput.y * RightStickMultiplier.y : mouseInput.y; - bool jumpInput = Input.GetButtonDown("Jump"); + bool jumpInput = Input.GetButtonDown( jumpButton ); Current = new PlayerInput() {