Hi All, i'm totally new to Unity, and what i'm trying to test in this moment is rotating a shape to have it to move like an airplane. For my first step i'm ignoring physics,rigidbodies and so on. What i want to achieve are these objectives: 1) when i move my mouse up, it has to go down (related to its facing) 2) when i move my mouse right it has to roll on its Z axis. I produced some code that doesn't work, the rotations looks randomly and from time to time it looks like it goes in gimbal lock.
Could please someone suggest me the correct direction to follow? Thank you.
this is the wrong code.
// rigidbody.AddForce( ( transform.forward ) * playerSpeed ); rotationZ = Input.GetAxis("Mouse X") * xSensitivity * 0.02f ; rotationX = Input.GetAxis("Mouse Y") * zSensitivity * 0.02f ; Quaternion newRotation = new Quaternion( rotationX , 0 , rotationZ ,1); if( (rotationZ != 0) || (rotationX != 0) ) { target.transform.rotation = Quaternion.Slerp(target.transform.rotation, newRotation , Time.deltaTime ); }