I have a few lessons here and there covering some rotation using mouse input like this one: https://cgcookie.com/lesson/rotating-turret
This is a code snippet I’m using in a current project for rotating a tank’s turret:
void BaseRotation ()
{
moveX += Input.GetAxis("Mouse X") * speed;
baseRotation = Quaternion.Euler(0, moveX, 0);
turretBase.rotation = Quaternion.Lerp(turretBase.rotation, baseRotation, smooth);
}
This just works off the Horizonal axis of the mouse, but you could also add in the Y axis as well. So something like this:
void BaseRotation ()
{
moveX += Input.GetAxis("Mouse X") * speed;
moveY += Input.GetAxis("Mouse Y") * speed;
baseRotation = Quaternion.Euler(moveY, moveX, 0);
turretBase.rotation = Quaternion.Lerp(turretBase.rotation, baseRotation, smooth);
}
So in that code snippet you’re moving both along the X and Y axis. The horizontal axis (Mouse X) rotates the object along the Y axis (like turning your head) while the Vertical Axis (Mouse Y) rotates the object along its X axis (looking up and down). Speed and Smooth are float values that just help it move faster/slower. Hope that helps.