IN THIS ARTICLE
Use collision groups to define the layers that a collider interacts with. A collision group is similar to a mask with specific bits set in which each bit corresponds to a collision layer.
Two colliders interact if their collision layers are in each other’s collision group. If one collision layer is not present in the other layer’s collision group, the colliders don’t interact.
To create a collision group
In O3DE Editor, choose Tools, PhysX Configuration.
Click the Collision Groups tab. The layers that are configured on the Layers tab appear here as columns.
Click Add, and then enter the name of the group into the text box.
Select or clear the check boxes to specify the layers to include in each collision group.
Close the configuration tool. The configuration tool must be closed for changes to the groups to take effect.
To assign a collision group to a collider
In the O3DE Editor viewport, select the entity that has the collider.
In the Entity Inspector, in the PhysX Collider component, for Collides With, choose one of the collision groups that you created from the drop-down list.
The following example defines Player, Enemy, Bullet, Foliage, and Terrain layers, and the following collision groups:
- PlayerBullet - Collides with Enemy and Terrain.
- EnemyBullet - Collides with Player and Terrain.
- TerrainCollision - Collides with Player, Enemy, Bullet, and Terrain.
- PlayerCollision - Collides with Enemy, Bullet, and Terrain.
A bullet fired by the player has the following layer and group:
- Layer: Bullet
- Group: PlayerBullet
A bullet fired by the enemy has the following layer and group:
- Layer: Bullet
- Group: EnemyBullet
Note:You don’t have to define an “enemy bullet” or a “player bullet” layer. Instead, you have a single Bullet layer and create separate collision groups to specify the objects that it collides with.
Copyright © 2022 Open 3D Engine Contributors
Documentation Distributed under CC BY 4.0.
The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our Trademark Policy page.