how to make an object follow the player in 3d

I’m making a game where several cubes will follow the player I wanted to know how to make them follow the player in a straight line

Hi,ameba_invertida
You may try to use Vector3.MoveTowards or Lerp.

using UnityEngine;

public class MoveTowards : MonoBehaviour
{
    public float speed;
    public GameObject target;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.position = Vector3.MoveTowards(transform.position, target.transform.position, speed * Time.deltaTime);

        //Alternate Solution
        //transform.position = Vector3.Lerp(transform.position, target.transform.position, speed * Time.deltaTime);
    }
}

Feel free if you have any other questions. Hope this helps :slight_smile: