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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Respawning a prefab which has been, Destroy(This);

Discussion in 'Editor & General Support' started by Vexos, Jun 20, 2015.

  1. Vexos

    Vexos

    Joined:
    Jun 1, 2015
    Posts:
    19
    Hello! I've been crying to myself and on my pillow for a couple of hours now and decided I would take help from some better coders. So! Let's dive right in it.

    I've got one script which adds one value (key), it destroys the object and adds an image on the screen, everyone happy, but! I later got a collider taking in all the keys for storage, im now trying to make the prefab (key) to spawn again freshly, keep in mind I've got a script allowing it to spawn at random cordinates at startup I dont know if this works in runtime.

    If anyone could help me with this simple script I cant figure out myself that would be wonderful. And also! If any misspellings were made during this post, it is very late here and I didnt sleep last night so pardon me <3.
     
  2. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    You can spawn it in runtime like at startup, with GameObject.Instantiate(yourprefab);
     
    Vexos likes this.
  3. Vexos

    Vexos

    Joined:
    Jun 1, 2015
    Posts:
    19
    Thank you very much! I just figured it out because of you!