Skip to content
This repository has been archived by the owner on Feb 13, 2018. It is now read-only.

Made the example PlayerInputController enable or disable camera axis … #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions Assets/SuperCharacterController/Scripts/PlayerInputController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
{
Expand Down