How to make prefab move to random closest point?

i have a network of waypoints. And how prefab can randomly choose one of few points that exists in certain radius and move to that points, after that move to the next randomly choosed point in certain radius and so on.

Which function i need to use to find waypoints in certain radius?

And how than move object to this point?

1 Answer

1

You could use Vector3.Distance to find the distance of your waypoints transforms from some origin.

Gather all the waypoints within distance into a list, then select one of them out of random for example.

To move an object, consider Vector3.MoveTowards or transform.Translate.