Code to make the camera track the player...

I need a code that can allow me to have the camera follow the player, I’m making a 3D run game kinda like Subway Surfers, but it follows the player everywhere, can someone help me figure this out?

You can input camera as a child to character in hierachy or if you want camera to be some kind of independent use such script. Offset is standart position for camera which you give as you like. Put this sript to camera and than drop you character in that script (in inspector)

public GameObject player;
    private Vector3 offset = new Vector3(0f, 0f, 0f);
    // Start is called before the first frame update
    void Start()
    {
        
    }

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