x


How to have vertical and horizontal axis work at the same time

Ok,What i'm trying to do is to rotate an object in Roll(left/right) and Pitch(forward/back) axises like this:

function Update(){
    var horizontalRotation = Input.GetAxis("Horizontal") * rotationSpeed;
    var verticalRotation= Input.GetAxis("Vertical") * rotationSpeed;
    var rotationVector = Vector3(verticalRotation,0,-horizontalRotation);
    transform.Rotate(rotationVector * 0.1);
}

what happens is that, when for example the up arrow is pressed first, the left or right arrow does not make any change to the rotation anymore. Basically it only gets the first pressed button and ignores whatever comes after until the first button is released. how to fix this? thanks,

more ▼

asked Nov 21 '10 at 11:00 AM

Kourosh gravatar image

Kourosh
1.5k 48 53 65

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Works fine for me.

Is it possible you have a pretty old or dirt cheap keyboard? What could be happening is that your keyboard may be overloading the signals for the two keys, which was a common practice with older keyboards. Try pressing W and the left cursor at the same time for example instead of up and left, see if it rotates in both directions. If it does, it could well be your keyboard

more ▼

answered Nov 21 '10 at 03:23 PM

Mike 3 gravatar image

Mike 3
30.7k 10 67 256

Yep, I was terribly wrong! the problem was from the rest of the code. I was trying to put some angle limitations for Roll and Pitch which were not functioning correctly. But thanks, you assured me that the problem rested somewhere else!

Nov 22 '10 at 08:40 AM Kourosh
(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:

x982
x747
x40
x36
x35

asked: Nov 21 '10 at 11:00 AM

Seen: 918 times

Last Updated: Nov 21 '10 at 11:00 AM