- Home /
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,
Answer by Mike 3 · Nov 21, 2010 at 03:23 PM
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
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 $$anonymous$$ch which were not functioning correctly. But thanks, you assured me that the problem rested somewhere else!