I’m trying to instantiate gameobjects on UI menu panel, it works well but whenever i refresh the menu it keeps spawning new clones. I want to delete clone object if a new one spawns, so i can keep only one at once.
Check out procedural generating objects videos all over youtube but the key to get it to work for me is to have a saved bool that is true if the object is there & false if its not. Then reference that saved bool so your code knows if it needs to spawn or delete the object. It should trigger the bool to false when deleted and setting the bool to true when spawned. Try using Visual scripting or Bolt if you are new to coding
Thanks mate, i could fix the problem just adding an if statement.
if (clone== false)
clone = Instantiate(goPrefab), gameObject.transform).GetComponent();
something like this. Tried to change variable names to be clear. Sharing in case of somebody stucks with the same issue.