Good evening everyone, this one is probably pretty simple but I’m not seeing the problem. I have structure objects that are instantiated and built in my game. The structures all have a spawner class which spawn units. Now, the spawner class is responsible for getting a path from the path finding system when it is first built by the player. This is so every unit it spawns does not have to run the path finding algorithm which saves quite a bit of resources.
However, there’s something strange happening. The path found by the spawner is passed to a unit upon that unit’s instantiation. It seems like the units are all sharing the same Queue. I know this has something to do with the queue being a reference or not but I’m not sure why this would be the case. Do I really have to grab all the nodes from the queue manually and push them into a new Queue before passing it to the instantiated unit?
I wrote a bit of debug code to print out the nodes inside of each unit’s path Queue upon instantiation, here’s what that looks like as the unit’s are spawned. This is each of there queues: