Beginner question about camera control.

Hey, i’m learning Unity, doing tutorials on Youtube (currently on the Roll-A-Ball tutorial) and wherever. Ran into a problem concerning the camera control. I scripted the camera with this script :

public class CameraControl : MonoBehaviour {

    public GameObject player;
    private Vector3 offset;

    void Start ()
    {
        offset = transform.positon - player.transform.position;
    }
   
    // Update is called once per frame
    void LateUpdate () {
        transform.position = player.transform.position + offset;
   
    }
}

The problem is that it didn’t create a “slot” in the camera object’s properties, where i could attach the player object to. “public GameObject player;” Should create it, if i understood correctly?

I couldn’t find an error in the code, compiler says there is. English isn’t my native language, and i’m still learning Unity, don’t know the right terms so i hope you guys get what i’m trying to say.

Hi,

Your line 8 is like this:

offset = transform.positon - player.transform.position;

Try this:

offset = transform.position - player.transform.position;

So there is typo: positon → position