Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Why Does My GameObject Not Spawn Anymore?

Discussion in 'Scripting' started by ExcitedMormon, Aug 14, 2014.

  1. ExcitedMormon

    ExcitedMormon

    Joined:
    Aug 3, 2014
    Posts:
    7
    Why does my gameobject not spawn if I don't grab it? The other gameobjects spawn just fine even after not grabbing it, but not this certain one. I think it's because it doesn't reset if I don't grab the gameobject. If you look at the script I posted below: When I collect 10 "Item1" gameobjects, it spawns in the "Coin" gameobject, and when I grab it, it completes it, but when I don't grab it, the circle doesn't get complete so it stays like that forever and never spawns the "Coin" again. So what could be causing this? Here's my GameObject script(this script spawns both the gameobjects I need to collect(Item1) and the one that doesn't respawn if I don't grab it(Coin)): http://pastebin.com/iDmiHWcy

    Now I have a pretty good feeling that it's defiantly the script that I posted that's the problem. I tested it with a different spawn script and the gameobject respawn/kept spawning even after not grabbing it. I know this is pretty a vague explanation and question, so I'm really sorry. Anyways I hope someone can help me see what's the problem here. Anyone?
     
    Last edited: Aug 15, 2014
  2. hariavm

    hariavm

    Joined:
    Aug 18, 2014
    Posts:
    73
    check the boolean spawned.
    u change this valuse in ontriggerenter function,so only it happen,try to change in update fn
     
  3. ExcitedMormon

    ExcitedMormon

    Joined:
    Aug 3, 2014
    Posts:
    7
    Thanks yeah I figured out before you commented that it was the boolean spawned, but your awesome for noticing that. Thanks anyways. :)
     
  4. hariavm

    hariavm

    Joined:
    Aug 18, 2014
    Posts:
    73
    always welcomeee