- Home /
Question by
Brylos · Dec 07, 2016 at 09:46 AM ·
inputjoystickxboxcontroller
Xbox controller joystick axis small movements?
Is there a way to get the input of an xbox controller joystick so it can detect if I'm pushing it only slightly or pushing it all the way? I want to have it so when I only push it slightly, my player walks, then if I push it all the way, he runs. Thanks in advance.
Comment
Best Answer
Answer by Delthrox · Dec 07, 2016 at 02:37 PM
Hi,
yes you can. I'm using a similar method to account for the deadzone from a joystick. You can use it as follows:
Vector2 stickInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));
float stickMagnitude = stickInput.magnitude; //this gives you a float value between 0 and 1 of how far the joystick has been pushed.