Entity Creation Event

Hello, I have dug into the documentation, but could not found any entity created/deleted or hierarchy changed events. Is there any event to achieve this?

Hey @SiyahaS! On the page below you will find an answers on your questions.


Hello, this is about creating entities at runtime, I am looking for an event that is called after any entity created. Like a tracker. I want to loop over all entities but if i were to use Entity.find every update it would consume way too much resources. Instead I could use an event to register/unregister all the entities based on create/delete events if possible. Is there anything like that?

I assume you create the entity by script? Then you can add the entity to an array after creating. Otherwise I don’t understand what you mean.

That would mean coupling all the scripts with a utility script. But if there is none I guess that is a way to achieve that. Still I thought there would be an event for entity creation.

It is not clear to me what you are trying to achieve so I will leave this question for someone else.

There’s no public API for it but I think there may be some private events in the engine itself.

Are the entities created by the app? It sounds like the best way would be to make a utility function that you use to create and destroy entities.

These will be wrappers around the normal create and destroy functions and can fire events on the application object or wherever you need them to be.

While there will be dependency on the utility functions, you won’t need maintain a global array or structure.

Or alternatively, if you are tracking a specific entity or set of entities, you can add a script to them that on initialise, fires an event with itself as the event param that the tracker is listening for. And you can do the same for the ondestory event to untrack.

There’s a few variations on the above to do the tracking depending on your needs.


As a further alternative, you can use entity tags and findByTag which I believe is cheaper as they are already tracked in a map or dictionary I think.