- Home /
Prefabs & Instances
I have a bunch of prefabbed characters that all have a "unitAI" C# script attached to them. One public variable in this ai script is a public enum list, which contains "player," "neutral," or "enemy" strings, and another public variable for me to choose which Owner the unit belongs to. Currently, whenever I make any change to the unit's other variables and apply it to the prefab, it'll change this Owner enum value to this particular instance.
So, if I've already placed a dozen of this unit in an area as Neutrals, and now I'm planting a bunch of enemies and change any value on my prefab, ALL of these prefab instances now become Enemy instances. I understand that this is how prefabs are built to work, but is there a way to flag or tag my enum variables so that changing the prefab won't affect this one variable per instance?
Not as far as I know. $$anonymous$$aybe you should consider using a different prefab per setting, otherwise whenever you change a setting in the prefab all instances based on that prefab will change (as you very well know). So, either change the setting on the instances only, rather than the prefab, or have a separate prefab per setting you want to instantiate.
Answer by NGC6543 · Dec 27, 2015 at 01:05 AM
You'd better creating multiple prefabs for each "player", "neutral", and "enemy", I guess. That's exactly what prefab is intended to do.