How to use right analog stick from xbox controller to look around?
I try to use my xbox controller as input device. However the documentation fails to explain how to set it up.
E.g. how can I use the right stick from my xbox controller to look around, like in any game? Even such a common task is not documented.
Answer by MagicStyle · Nov 03, 2017 at 12:50 PM
I figured it out. You have to name the Y-Axis Control 'Mouse Y' and the X-Axis Control 'Mouse X'. And set the Y-Axis to 5th axis and the X-Axis to 4th axis. You also have to invert Mouse X
This is the most beautiful comment I've seen all month, thank you for this info
To use settings such as in the attached screenshot, I just use the following code:
float pitch = Input.GetAxis("Pitch");
float roll = Input.GetAxis("Roll");
:-)
I don't think it really matters what you name it, so long as you use 4th axis for x and 5th axis for y. For instance in projects where that controls the camera, it probably makes more sense to name it something like "Camera Horizontal" and "Camera Vertical"
Thanks so much @MagicStyle, this helped so much.,thanks so much @MagicStyle this helped so much.
Answer by trapazza · Mar 02, 2020 at 05:55 PM
The name is irrelevant, you can use whichever name you want as long you use that same name when calling Input.GetAxis( "that name" );
Answer by davidnibi · Jan 25, 2019 at 12:23 AM
Thanks. It's tricky to find documentation on this type of thing!
Answer by LelandGreen · Aug 25, 2020 at 12:13 PM
(I googled the subject and found this thread. However, it didn't work quite as advertised. So Just to be clear, I will make two posts – because I can only attach one screenshot/post).
First, for a wireless XBox Controller, I had to use Joy Num = "Joystick 3" to get this to work.
Second, the real advantage of using "Mouse X" and "Mouse Y" for the Name field is that it automatically maps the right joystick to "free look". (Or, to be clear, it's mapped to whatever the mouse movement is. Many 1st-person games use this layout.)
I confirmed this works by creating a new project, a simple Gaia scene, player and all. I made no other changes than to this input mapping, and it "automatically" works for Free Look action, just like the mouse.
*EDIT: While my previous answer worked for some time, I found a bug.
I discovered that the problem arises when you have over one controller. The number of the controller can change! (So "Joy Num" can change each time it's powered on.)
The only clean & quick solution I could find was to use Rewired. Slight learning curve, but after a morning with the manual, I could re-code the Gaia First Person Controller very simply. And it always works. Job done! Move onto the fun stuff. (Third person controller to follow, but I prefer FP for initial testing.)
Best regards and happy holidays to those now celebrating, Leland