- Home /
Rotation with Right Stick
I have the Logitech F710 controller and I am trying to get the rotation of a Character, like in most FPS games where you move the stick left and the character looks left and stops when you let go of the stick.
I meant the Right stick not the left. Sorry for the confusion. I am asking how to get the right stick to rotate the player like in a FPS game.
Answer by aldonaletto · Aug 10, 2011 at 12:32 AM
I suppose this controller will appear in the Input manager like any other gamepad. Usually the left stick is associated to the "Horizontal" and "Vertical" axes, and to access the right stick you will have to create two new axes in the Input manager (menu Edit/Project Settings/Input). Increment by two the Size parameter at the top of the Input Manager, then name the new axes as "RightH" and "RightV" (for instance), and set their characteristics. In my joystick (a popular chinese generic gamepad), RightH is the 3th axis, and RightV is the 5th one:
If you just want the camera to look right/left/up/down with the right stick, you can attach to the Main Camera a script like this:
function Update () { var angH = Input.GetAxis("RightH") * 60; var angV = Input.GetAxis("RightV") * 45; transform.localEulerAngles = Vector3(angV, angH, 0); }If you're using the First Person Controller prefab, disable MouseLook.js in the Main Camera (MouseLook also exists in the First Person Controller, but it's used to rotate the character right and left - don't disable this instance).
I get an error when I try that script. unity tells me there is a Type when it expects a variable, value, or method group. I'm new to coding so can you explain to me the problem and how to fix it? @aldonaletto
Answer by amirkrd · Apr 14, 2016 at 07:57 PM
hes right, but he forgot the "new" Beside the "Vector3(angV, angH, 0);" IF UR ON C-SHARP...C#
Your answer
Follow this Question
Related Questions
Referencing an object from one script to another, script reference doesn't help :/ 0 Answers
[FPS] Is it good to have the same character for AI and Players ? 1 Answer
Rotate object based on another rotation above a certain threshhold 1 Answer
Torque forces or Quaternion transforms for hovercraft rotations? 2 Answers
Rotating the player animation also rotates the player 2 Answers