Pick a Transform[] or GameObject[] from script?

Hi.

I wanted to improve my enemy AI by adding waypoints to it, so it would look a bit more realistic. I’ve got everything figured out, except for setting a random Transform or GameObject from a variable for them to go to. Is it possible, or do I need to find another way?

EDIT:
Does not need to be random. Just a way to pick them one at a time.

If we assume you have a list or array of items to choose from, you can use Random.Range() to pick an int between 0 and the length of your list, and use the Xth list item.

For something like that i would use a custom data class like this:

public class AIPath
{
    var waypoints : Transform[];
}

In your actual script you can define a public variable like this:

var paths : AIPath[];
private var currentPath : AIPath;

Now you can create multiple seperate pathes. To select a path, just use Random.Range like rutter said.

currentPath = paths[Random.Range(0,paths.Length)];

Then just use the waypoint array from the currentPath.

currentPath.waypoints[...]