Unity learning – FollowPlayer.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FollowPlayer : MonoBehaviour
{
    public GameObject player;
	private Vector3 offset = new Vector3(0, 10, -16);
	
	// Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
		// offset the camera behind the player by adding to the player's position.
        transform.position = player.transform.position + offset;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *