Indie-Game-Jam / Assets / Scripts / Player & Enemies / FollowPlayer.cs
FollowPlayer.cs
Raw
using UnityEngine;

/*
*  Copyright (c) Jonathan Carter
*  E: jonathan@carter.games
*  W: https://jonathan.carter.games/
*/

namespace CarterGames.NoPresentsForYou
{
    public class FollowPlayer : MonoBehaviour
    {
        [SerializeField] private Transform toFollow;
        [SerializeField] private Vector3 startPos;


        private void Update()
        {
            if (!transform.position.Equals(toFollow.position + startPos))
            {
                transform.position = toFollow.position + startPos;
            }
        }
    }
}