Physical System Configuration
The Project Settings -> Physical Configuration allows you to configure the related physics system.
Programmatic configuration
The physics system can be configured via . Some code examples are as follows:
let conf = game.config.physics
PhysicsSystem.instance.resetConfiguration(conf);
For more API content, please check the PhysicsSystem interface please refer to: .
Collision Matrix
The collision matrix is a further wrapper around the function, which is used to initialize the groups and masks of physics elements.
By default the collision matrix has only one DEFAULT group, new groups do not collide with other groups by default.
Click the + button to add a new group. The Index and Name of the new group cannot be left unfilled.
- Index represents the collision group value, which supports up to 32 bits, i.e. the value range is . Group values cannot be repeated.
The figure shows the configuration of a collider group for a flying shooter game. As you can see from the figure, when a group is added, the panel appears with the names of the groups both horizontally and vertically. Let’s call the horizontal part Group and the vertical part Mask. Suppose we now make the following checkboxes:
This configuration means that the group ENEMY_PLANE can collide with the groups ENEMY_BULLET and SELF_BULLET. Here the group ENEMY_BULLET and SELF_BULLET are the masks of the group ENEMY_PLANE. Similarly, for the group ENEMY_BULLET, ENEMY_PLANE is also its mask.
Once the collision matrix is configured, you can add the RigidBody component to the object to be collided with and set the collision group Group
.