I am trying to limit the rotation only to the y-Axis i.e I want the object to only rotate around it self in y-axis. But I am not able to do this.
Please help to solve this issue.
Thanks in advance.
Use this script
public class Rotate : MonoBehaviour
{
public float rotationSpeed = 0.7f;
[System.Obsolete]
void OnMouseDrag()
{
float XaxisRotation = Input.GetAxis("Mouse X") * rotationSpeed;
// float YaxisRotation = Input.GetAxis("Mouse Y") * rotationSpeed;
// select the axis by which you want to rotate the GameObject
transform.RotateAround(Vector3.down, XaxisRotation);
// transform.RotateAround(Vector3.right, YaxisRotation);
}
Do rem to put a box collider on the game object u want to rotate else it would not work.