Randomising Each GameObject Array for different Instance C#

Hey guys, I’ve hit a bit of a stump here, i have a script that controls 32 Fish and 3 Whales and have 15 way points.

The part of the Code I am struggling with is:

void Start () {
    waypoints = GameObject.FindGameObjectsWithTag("Waypoint");
    waypointInd = UnityEngine.Random.Range(0, waypoints.Length);

How can I make this so, for each Instance of the Script… eg Each fish, takes a randomised path rather than all fish flocking to the same way point…

This script as is works very well, and it picks a randomised path on each startup… but the issue I’m having is all the fish have the same randomised path…

i have tried re-arranging the position of all the fish, spread out over the whole water space, but they all manage to form a big line going to the one way point.

I see two easy solutions.

(1): Use Random.InitState(int) with an incrementing index / random value each time a new fish is initialized (storing the index as a public static variable and incrementing / modifying it in Start(), after Random.InitState()). That way, each fish has a new seed for its random waypoint finder.

(2): Generate a masterlist of waypoints that contains the target waypoints of all fish, generated by a second script (perhaps you could attach it to a GameObject that all the waypoints are children of, so you can call waypoint by child number instead of using FindGameObjectsWithTag(), which is slow), and have all fish reference that script’s waypoint array via their own index to see which waypoint they were assigned.

That having been said, I’m surprised that a single random seed isn’t working for you in this case. Are all of your waypoints tagged “Waypoint”?