I have a virtual joystick to rotate the player and this piece of code works nice and smooth for the rotation of the players view.
public void rotatePlayer(Vector3 newPosition){
transform.Rotate(new Vector3(-newPosition.y,newPosition.x,0)*Time.deltaTime);
}
I pass a Vector3 with the position of the joystick in relation of his parrent's(the joystick border) anchor.That gives me the rotation direction.Which means that if I set the rotation of the camera direclty it will just flip to that point and not move progresively to that point.
Even though z is set to 0 in the vector3, it changes the z axis angle of the camera. How can I clamp it to 0 without using many resources?
I tried other methods but they just switch the camera's rotation directly when the joystick is touched like I already said.Flip and stop.
I guess I could just set the z axis rotation to 0 every time but that just seems like double work.