Answers for "how to not destroy an object in unity"

C#
4

how to destroy object in unity c#

// To remove a GameObject attached to this script instantly
Destroy(gameObject);
// To remove a GameObject attached to this script
//in certain time (5 seconds for this example)
Destroy(gameObject,5);
Posted by: Guest on April-28-2022
9

how to destroy an object in unity

Destroy(gameObject);
Posted by: Guest on February-01-2021
-2

destroy gameobject unity

void OnTriggerEnter()
{
    if(PlayerPrefs.GetInt("GotPotion", 0) == 0)
    {
        // You didn't get the potion yet, so get it
        Destroy(gameObject);
        PlayerPrefs.SetInt("GotPotion", 1); // got the potion
    }
}
Posted by: Guest on March-24-2022

Code answers related to "how to not destroy an object in unity"

C# Answers by Framework

Browse Popular Code Answers by Language