Drop Function

How do I add a drop item function in unity after a monster has died or been destroyed?

It’s in javascript is what I am getting at.

Thank you!

According to this, there isn’t a GameObject.onDestroy() method.

So to me, I would make a work around to check when a monsters HP has reached <=0, and create a drop function for that monster class. Or simply when you call Destroy(object), you should call a drop before that, as you would would probably still want some information from the object before its gone.

That would go on for you to specify a drop method, as well as a loot table per mob. But regardless I think thats your best bet!

1 Like

That answer is ancient. There’s very much an OnDestroy message these days:
http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDestroy.html

Regardless, you should be careful creating new things in OnDestroy. Therefore I think the workaround mentioned is very suitable.

1 Like