0
Answered

Newbie - Action when object is destroyed

VictorSB 5 months ago in Game Creator updated by Marti (Lead Developer) 5 months ago 3

Hello everyone, 

First question of a newbie with game creator, is there a way of doing one of these two things?

a.) execute an action right after a GameObject is destroyed with an external trigger of some kind

b.) execute right before the GameObject is destroyed via Destroy()

Thank you!

Unity version:
2019
Game Creator version:
1.1.6
Answered

There's no "On Destroy" callback at the moment. However, when an object is destroyed, the OnDisable Trigger is also called. You could use that one to hook your Actions.

As for executing an Actions list right after the object is destroyed... I'm afraid that's not possible The OnDisable Trigger is attached to the object being destroyed, so if it's removed from the scene, so is the Trigger. Unless, you call another Actions object after detecting the OnDisable.

+1

Thank you Martí, I tried the onDisable trigger and worked like a charm.

I appreciate your fast response.


Let me take the opportunity to congratulate you for GameCreator and your additional modules, I have acquired most of them during the unity spring sale and I am truly impressed and inspired.


Regards

Thank you for your kind words :-) Happy game making!