unload an object? C#

Hi again,

I’m loading an object using:

 Instantiate(Resources.Load("star", typeof(GameObject)));

How can i unload it when the animation is finished?

Thanks guys :slight_smile:

First go to Edit > Project Settings > Tags And Layers and add a tag named star then select your star in the assets and click on tags and tag it with “star” tag then add the following to your script

void Update ()
{
   if ("Change this with your if animation finished bool")
   {
       GameObject.Destroy(GameObject.FindGameObjectWithTag("star"));
   }
}

Thanks Malebakeer!

So I’m kinda noonish at this stuff, what would be the syntax to check if the animation has finished?

Thank you so much for your help!! :slight_smile:

Cheers