Physics Based Events
Certain physics-based events are emitted during simulation. They can be listened to in a script or in the code of your application.
The events that are emitted belong to a globally accessible event map called physics.events.
Trigger Events
The trigger events that can be listened to are the enter_trigger event and the exit_trigger event. The enter_trigger event is sent when a trigger body enters another body (or vice versa). The exit_trigger event is sent when a trigger body exits another body (or vice versa).
These two events are emitted on the entity that is the trigger physics body, and in the data of the event is contained the other entity that entered/exited the trigger. More info on this below.
Collision Events
The collision events that can be listened to are the collision_enter event and the collision_exit event. The collision_enter event is sent whenever a non-trigger physics body begins to overlap with another non-trigger physics body. Coincidingly the collision_exit event is sent whenever a non-trigger physics body stops overlapping with another non-trigger physics body.
These two events are emitted on both entities involved in the collision. The data of the event contains the other entity that was involved in the collision. More info on this below.
Listening to Events
These physics events are no different to other events in 3dverse. They belong to an event map and can be listened to within a script or within application code.