How to move Instantiated object to pre-defined position(Solved)

How would I make an instantiated object move to a pre-defined position(transform).

I guess in simple terms I mean a single waypoint, nothing too technical to start with. just instantiate and move.

(I’ll add multiple waypoints using arrays later, but for now simple is the goal)


You can use Vector3.MoveTowards like below:

GameObject go;
Vector3 movePosition = new Vector3(10f, 10f, 10f);
float speed = 5f;

void Start()
    go = Instantiate(prefab, transform.position, Quaternion.identity);

void Update()
    if(go.transform.position != movePosition)
        Vector3 newPos = Vector3.MoveTowards(go.transform.position, movePosition, speed * Time.deltaTime);
        go.transform.position = newPos;