Prefab Script List not being assigned as unique - can you see why?

First, thanks for any help here - I’m reluctant to ask because it’s probably something obvious I’m missing but i’ve been looking at it too long…

The scenario is I have a holder object with a pathfinding script (working fine) and an event-based assignment script.

The objects being assigned are a group of instantiated prefab characters with a script added that navigates the path calculated from the pathfinding script when assigned from the assignment script.
If they all follow the same exact path, it’s working great.

What I am trying to do is append a unique “final location” for each prefab. Think of a bridge crew running on to the bridge then breaking up to battle stations.
Here is the simplified assignment script:

`public List RunPath; //populated by the pathfinding script
public bool ExecutePath;//set by the pathfinding script once the entire path is calculated
public GameObject CharacterArray;

void Start ()
{
%|-147361493_1|%
%|-950286578_2|%
}

void Update ()
{
%|1226425402_3|%
%|737211570_4|%
%|-481316925_5|%
%|1764865785_6|%
%|177424711_7|%
%|882064304_8|%
%|306964567_9|%
%|-1581774797_10|%
%|-958725657_11|%
%|-1565622815_12|%
%|-1720740372_13|%
%|130943564_14|%
%|-98425953_15|%
}
`
The issue is every prefab has a public List Path; variable and every prefab is getting every vector3 added to Path from CharacterFinalPositions[intClassCount]) which is the List of unique final positions. In other words, each prefab should get just one but instead, each prefab is getting them all.

Thanks again for any advice.

nextCharacter.GetComponent().Path = ClassPath;
This line doesn’t create a unique copy of the list for each object, it just assigns a reference to the list you already have. Since all the objects are referencing the same list, all the endpoints get added to that single list and the objects all follow the same path.

You will have to make sure you are creating a new list for each object before you add the unique end point to it.

This will, of course, create a lot of lists with mostly the same elements and waste memory. As an alternative, you could give all your objects a reference to the base ClassPath list, but store the endpoints in a separate Vector3 variable for each object.