- Home /
Question by
thedodgeruk · Sep 30, 2012 at 01:54 PM ·
destroymessage
send message to via instanceID
i have a script that when an object is desctroyed it needs to send a message to the object that destroyed it. the best way to do this would be to have the instanceID of the desroying object. and when an object is destroyed it sends a message to the destroyingobject via its instanceID , but i can not find code that will allow me to do a search via InstanceID ?
is there one?
Comment
wen you say "destroyed" you mean with a collider ?
if so, from the collision, get the game object, the go GetComponent(scriptName) to get the script, and then you can get any variables (say an ID number), or anything you want in there
Do what @Fattie says or cache the actual object - no point using InstanceIDs...