|
2 | 2 | layout: manual
|
3 | 3 | language: en
|
4 | 4 | github: https://github.com/defold/doc
|
5 |
| -toc: ["Collision messages","Collision response","Trigger response"] |
| 5 | +toc: ["Collision messages","Event filtering","Collision response","Trigger response"] |
6 | 6 | title: Collision messages in Defold
|
7 |
| -brief: When two objects collide, the engine will broadcast messages to all components in both objects. |
| 7 | +brief: When two objects collide, the engine may call the event listener or broad cast messages. |
8 | 8 | ---
|
9 | 9 |
|
10 | 10 | # Collision messages
|
11 | 11 |
|
12 |
| -When two objects collide, the engine will broadcast messages to both objects: |
| 12 | +When two objects collide, the engine will may send an event to the event callback, or broadcast messages to both objects. |
| 13 | + |
| 14 | +## Event filtering |
| 15 | + |
| 16 | +The types of events generated may be controlled using the flags for each object: |
| 17 | + |
| 18 | +* "Generate Collision Events" |
| 19 | +* "Generate Contact Events" |
| 20 | +* "Generate Trigger Events" |
| 21 | + |
| 22 | +These are all `true` by default. |
| 23 | +When two collision objects interact, we check if we should send a message to the user, given these checkboxes. |
| 24 | + |
| 25 | +E.g. given the "Generate Contact Events" checkboxes: |
| 26 | + |
| 27 | +When using `physics.set_listener()`: |
| 28 | + |
| 29 | +| Component A | Component B | Send Message | |
| 30 | +|-------------|-------------|--------------| |
| 31 | +| ✅︎ | ✅︎ | Yes | |
| 32 | +| ❌ | ✅︎ | Yes | |
| 33 | +| ✅︎ | ❌ | Yes | |
| 34 | +| ❌ | ❌ | No | |
| 35 | + |
| 36 | +When using the default message handler: |
| 37 | + |
| 38 | +| Component A | Component B | Send Message(s) | |
| 39 | +|-------------|-------------|-------------------| |
| 40 | +| ✅︎ | ✅︎ | Yes (A,B) + (B,A) | |
| 41 | +| ❌ | ✅︎ | Yes (B,A) | |
| 42 | +| ✅︎ | ❌ | Yes (A,B) | |
| 43 | +| ❌ | ❌ | No | |
13 | 44 |
|
14 | 45 | ## Collision response
|
15 | 46 |
|
|
0 commit comments