how to destroy an object in unity

105

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
    }
}

Comments

Submit
0 Comments