Deleting a game object from within it's self.

Hello, me again.

I want to be able to remove my AI from the game after X amount of time from within it’s self.

I’m probably missing something basic, but that’s how it is with me today :expressionless:

Cheers.

You are missing something basic, but these things happen to us all from time to time.

Object.Destroy(this.gameObject)

Destroy is funny, because it will destroy the calling component if it is just called without arguments. If you pass it a GameObject, that object will be destroyed. If you call it on the GameObject itself, then it will destroy it at the end of the Update loop.

Do you mean like this

(ie)

Destroy (gameObject, 5);

Thanks you two. I forgot all about that damned reference page! :stuck_out_tongue:

Whoops, you did say “after X amount of time,” didn’t you? Well, BM covered you there. You’re lucky somebody around here can read.

1 Like