How do I make a camera follow something

I want to know a simple way to make my camera follow a specific object, using as little script as possible.
is there anything that would work similarly to “Cube.Vector3coordinates = Camera.Vector3coordinates”

import free asset names Utility (i think) which have script that you need

–

Is your camera already child to a player?

–

2 Answers

2

If you start with:

this.transform.position = objectToFollow.position;

the camera will be on the same position as the player, so you will need to offset it using:

this.transform.position = objectToFollow.position - (objectToFollow.forward * offset);

this will offset the camera behind the player, if the player rotates the camera rotates with him.
This would be a basic follow script that you can extend with some smoothing and control for height and others stuff.

My pleasure!

–

Here is a great Tutorial made my Unity

Roll-A-Ball Series

Moving the Camera Following