Are Tags the best solution for this? Duplicating an item that duplicates itself a set amount of times.

I have some code that causes a gameObject to out so far and duplicate itself multiple times before it destroys itself. I need to limit the amount of times that this happens. It might happen once or it might happen 3 times. The duplicated objects will duplicate as well and then it will go on forever.

I am just trying to figure out the best way to limit this. GetComponent seems like it would not work well. Tags seem to be the easiest way to implement this. When a gameObject with “Dupe3” spawns it will spawn gameObjects with tag “Dupe2” etc. Until its finally done.

You could expose a public property on the Monobehaviour. Something like below.

public class Duplicator : Monobehavior {
  [SerializeField] Duplicator prefab;
  public int level;

  void Start() {
    if (level > 0) {
      GameObject g = Instantiate<Duplicator>();
     g.GetComponent<Duplicator>().level = level - 1;