I have a game in Unity in which I have added three objects (Cube, Cylinder, Capsule). To these game objects, I have added a script to rotate them along an axis when they press the left click and x, y or z, rotating the object along the respective axis. But when I attempt rotate a single object, the other objects rotate too. How do I rotate each object without affecting the other objects.
if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.Z))
{
transform.RotateAround(transform.position, transform.forward, Time.deltaTime * 90f);
}
if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.X))
{
transform.RotateAround(transform.position, transform.right, Time.deltaTime * 90f);
}
if (Input.GetMouseButton(0) && Input.GetKey(KeyCode.Y))
{
transform.RotateAround(transform.position, transform.up, Time.deltaTime * 90f);
}