Issue Instantiating a new prefab

Alrighty, so I’m kind of new to unity, and I’m not sure what exactly is going on. But my issue is:

I have a prefab named UnitStack (it’s an object that contains up to 8 units in a list and gives me extra functions to use the group). Well, if you want to remove a unit from the UnitStack but share the space with no alternative stack, I need to create a new one. In my script I added:

public UnitStack unit_stack;

Then in the editor I associated that to my prefab for a UnitStack. My problem is that when I call instantiate and reference unit_stack, it instantiates a copy of my current stack. So instead of removing one unit into a new stack…it recreates the entire stack and then adds the unit to it, so there are way too many units in the new stack.

Why is my Instantiate creating a copy of my current UnitStack game object instead of a fresh empty one?

Are you pointing the reference to the prefab in the project or on the stage? Also when you instantiate are you assigning it to unit_stack? If so, you are cloning the clone over and over.

Yeah so in my project I gave my UnitStack prefab a reference to itself essentially, which makes sense why I would be getting a clone of the current clone.

What are the best ways to resolve this?

I really quickly tried making a new game object called PrefabGenerator, gave it a reference to my UnitStack and had it instantiate some new UnitStacks. The first one worked, it gave me an empty stack and moved the Unit into it’s list. But when it instantiated a 2nd UnitStack, the 2nd stack had the unit from the first test in it. So basically, it made a clone of the first UnitStack again, instead of a second new one.