Search Unity

how do i recreate a destroyed object

Discussion in 'Scripting' started by drazil austin, Jan 4, 2011.

  1. drazil austin

    drazil austin

    Joined:
    Dec 16, 2009
    Posts:
    236
    i am building a mazemaker game and so far its working really well. i recently am attempting to add gates but in order to remove switches i have to destroy them (unless there is a better way). but when i want to put a switch back in the spot i removed one from it throws an error

    what should i do to fix this?
     
  2. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    What does the code look like where that error is getting thrown?
     
  3. Teriki Tora

    Teriki Tora

    Joined:
    May 21, 2010
    Posts:
    132
    Have you tried using the object as a prefab? I had the same problem with my projectile, where, when my test-platform deleted itself, my projectile wouldn't create the platform anymore. Having a gameobject (hidden) that creates your prefab-objects after they're deleted might help. Either that or hide them after they're "destroyed". (Not really destroyed, but actually hidden, ready to be used again)
     
  4. drazil austin

    drazil austin

    Joined:
    Dec 16, 2009
    Posts:
    236
    nvm i figured it out