Okay so this is a script for the movement of the camera. And I want it to follow the cube called “Player”.
I know I need to access the transform of “Player” but how. So how can I make a variable called “player” that can access the transform of the cube, so I can put it in as player.position?All I need is the variable. Help please!
public float rotationSpeed = 20f;
if (Input.GetKey (KeyCode.R)) {
transform.RotateAround(player.position, rotationSpeed * Time.deltaTime);
}
Though doing it in this method seems a bit… Inefficient, you can get your players GameObject, and just have the camera linked to the player in the hierarchy, to actually have it follow the player, then by script just do a LookAt with the camera to the referenced player.
public GameObject player;
void Update(){
camera.main.transform.LookAt(player.transform);
}