Answers for "how to destroy object in unity c#"

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
16

destroy gameobject unity

Destroy(this.gameObject);
Posted by: Guest on March-16-2020
7

how to destroy a gameobject in c#

Destroy(gameObject); // destroys the game object attached to the script
Posted by: Guest on July-15-2020
-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

C# Answers by Framework

Browse Popular Code Answers by Language