Hello!
I am attempting to have my Camera Move to different locations within my scene.
In unity, I have created some empty game objects to mark the different transform positions I want the camera to go to. On click of an object, I want the camera to jump to a designated location. With the code below, I am able to have the Camera move successfully on the first click. But, when I click on a separate gameObject (using the same script) I can’t get it to jump back to the first location. Instead, it moves ever so slightly towards the position.
I think I just don’t understand exactly how the transform Translate works, so if someone could clarify where I am going wrong, it would be greatly appreciated!
Thanks!
Code:
public Transform cameraLocation;
private void OnMouseDown()
{
Camera.main.transform.Translate(cameraLocation.position.x, cameraLocation.position.y, 0);
}