x


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.

more ▼

asked Jul 21 '11 at 09:23 AM

Kninja gravatar image

Kninja
1 1 1 1

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.

Aug 09 '11 at 05:02 PM Kninja
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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:

alt text

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).

more ▼

answered Aug 10 '11 at 12:32 AM

aldonaletto gravatar image

aldonaletto
41.3k 16 42 196

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2158
x1172
x520
x4

asked: Jul 21 '11 at 09:23 AM

Seen: 2378 times

Last Updated: Jun 19 '12 at 07:49 AM