Register an event that runs when an object is destroyed.
param action- The tag to match, only called for objects with a matching tag.
param unknown- The function that runs when an object is destroyed.
// This will run when the object is destroyed.
onDestroy(() => {
debug.log("ohbye");
});
let ghosty = add([
pos(),
]);
// Destroy the object
destroy(ghosty);
returns The event controller.
group Events