This article gives an overview of the current Entity Lifecycle in dot big bang. It’s an area under active development at the moment and we will post regular updates as things change.
In general you shouldn’t rely on the order of calling a callback to remain consistent for entities and components within an entity. As such you shouldn’t write code that requires an implicit ordering. For example relying on the Troll entity to always be updated before the Player entity without that being enforced.
start | is a catch-all initialization function, it is called whenever a component is added to an Entity. It should not be assumed that any other part of the Entity has been initialized when it is called. |
tick | is called once per game update. You can get the elapsed time since the last tick with this.game.frameDeltaTime. |
postCollisionTick | is called once per game update after tick and after our collision system has run for this frame. All the collision callbacks below are guarenteed to have run before this gets called. You can get the elapsed time since the last tick with this.game.frameDeltaTime. |
dispose | is called at the end of the frame if the Entity is to be removed or when a component is removed from the Entity. |
onMessage | is called at the beginning of the frame for every message that is sent to an Entity. Passes through the message name, a payload data object and information about the Peer that sent the message. |
Collision callbacks are only called on Entities with at least one Collision component that has a Static or Dynamic response type. All callbacks are symmetrical and both Entities involved will be notified of the contact.
onCollisionCorrection | is called when the collision system moves an Entity with the Dynamic response type. It passes a Vector3 representing the movement the collision system made. |
onCollisionEnter | is called when an Entity pair make contact. Passes through the other Entity involved as well as details of the contact. |
onCollisionStay | is called every game tick that an Entity pair is in contact. Passes through the other Entity involved as well as details of the contact. |
onCollisionExit | is called when an Entity pair leave contact. Passes through the other Entity involved. |
Trigger callbacks are only called on Entities with at least one Collision component. Note the response type is unimportant and all types will get trigger callbacks. All callbacks are symmetrical and both Entities involved will be notified of the contact.
onTriggerEnter | is called when an Entity pair make contact. Passes through the other Entity involved. |
onTriggerStay | is called every game tick that an Entity pair is in contact. Passes through the other Entity involved. |
onTriggerExit | is called when an Entity pair leave contact. Passes through the other Entity involved. |
start ()
tick ()
postCollisionTick ()
dispose ()
onMessage (name : string, data : any, sender : Peer)
onTriggerEnter (other : Entity)
onTriggerStay (other : Entity)
onTriggerExit (other : Entity)
onCollisionEnter (other : Entity, contact : CollisionContact)
onCollisionStay (other : Entity, contact : CollisionContact)
onCollisionExit (other : Entity)
For every entity and component in the game: