The Collision Add-On will enable you to detect when 2 or more components are touching each other. This mechanism will work regardless if components are fixed, moving or being dragged. If the components are visually touching each other or being overlapped this add-on will detect it.
How to Setup
- Open the Building Blocks on the left sidebar of the Editor
- Search for “Collision”
- Drag the Collision addon onto your project to enable it
- Add and configure pairs, please continue bellow
Pairs
The Collision Add-On will detect collision between Pairs of components. To define a Pair you should define what components belong to each side of the Pair. Given an example of birds and clouds, on one side of the pair you might be having 2 birds components (they can images components) and in the other side of the Pair you might have floating containers that represent clouds. For each Pair side you should define:
- Name – The name by which this pair side will be identified.
- Components which belong to this side of the pair (You can use specific components, tags or even a list components using our components selector ).
Pair triggers
When you create a pair you will also be able to specify which actions you want to run when the Pair is colliding. This is configured by clicking on the Triggers button in the top bar.
A Pair is said to be colliding if at least 1 component from each side is touching each other. It is also important to notice that the trigger will only execute once per pair collision. This means that if you have 2 birds and 1 cloud. When the 1st bird collides with the cloud the trigger will execute. But when the 2nd bird hits the cloud the trigger will not execute again – because the pair was already colliding. If you want to know exactly which components are colliding with each other you need to specify different pairs.
Pair Data fields
Each Pair will give you numerous data fields which you can use to configure your game mechanisms.
Has an up-to-date state of whether the pair is colliding or not.
How many total collisions happened in this pair.
Tells you how many components are currently colliding from side 1 (i.e birds)
Tells you how many components are currently not colliding from side 1
What are the components that are colliding from side 1. You can use this data field together with General Actions
What are the components that are not colliding from side 1. You can use this data field together with General Actions
Tells you how many components are currently colliding from side 2 (i.e clouds)
Tells you how many components are currently not colliding from side 2
What are the components that are colliding from side 2. You can use this data field together with General Actions
What are the components that are not colliding from side 2. You can use this data field together with General Actions
Pair Actions
Each pair will also give you actions which you can use to control if the add-on should be detecting collisions or not.
Starts detecting collisions among the pair components. All data fields will be updated once this action is executed, until we stop the pair.
Stops detecting collisions among the pair components. The data fields will not be updated, but they will keep their last value.
Stops the pair (see above) and also resets the data fields to their initial state. If you want to stop and reset data fields, executing the Reset Pair action is enough.
General actions
The Collision Addon also features actions you can use to control all the Pairs at the same time. These actions are useful if you have many Pairs and you want to control them in the same manner.
Starts all pairs
Stops all pairs
Resets all pairs