What it does
onDestroy is a lifecycle function: you write it in your script and the engine calls it. The engine calls it: entity destroyed. It receives no arguments.
The API says: entity destroyed
Signature
onDestroy()Arguments
It takes none.
Example · generated
function onDestroy() { ui.remove('hud');}onDestroy is not called, it is written. The engine calls it: entity destroyed. The body shown here is an example of what goes in it.