- Home /
AirPlane-Like Rotation ( like in GTA games)
I've been trying here for several hours with no sucess, i want to make my object rotate just like a airplane does in most games using the mouse: The Mouse X axis make it rotates around its center and the Y rotates it up and down locally. I've achieved something using this code here, but i couldnt get it to rotate around the local X( the vertical axis):
rotationX -= Input.GetAxis("Mouse X") * 10;
rotationY -= Input.GetAxis("Mouse Y") * 3;
transform.localRotation = Quaternion.Euler (0,0, rotationX);
but if i try to put the rotation Y on this localRotation thing ( on the first spot, right?) , it rotates around the global X axis, just like the image below:

Answer by ThiagoTejo · Nov 08, 2013 at 09:54 PM
I've made it! if someone have the same problem, use this:
rotationX = Input.GetAxis("Mouse X") * 10;
rotationY = Input.GetAxis("Mouse Y") * 10;
transform.Rotate(Vector3.right * rotationY);
transform.rotation *= Quaternion.Euler (0,0,-rotationX);
Your answer
Follow this Question
Related Questions
Rotate camera around player 2 Answers
Cannot instantiate rotation on Prefab 1 Answer
How get the rotation of an GameObject? 3 Answers
This can't be impossible or? Rotate (flip) smoothly from one point to endpoint on mouseclick. 3 Answers
rotate an object on the z axis so that it does not exceed 0-45 degrees 0 Answers