PhysicsWorld.PhysicsGroup
An identity shared by a set of shapes on one body so they are treated as a single object when reporting contact and trigger begin and end events. Assign a group only to shapes that belong to the same body. Two objects made of many shapes produce a begin and end event for every pair of shapes that touch. When each object's shapes share a group, the world marks the first begin event and the last end event between the two groups, so a callback can act on those alone and receive a single begin and end for each pair of objects. The marking is designed to be cheap, so it only examines the contacts of the two bodies involved, which is why a group cannot span more than one body.
Read time 1 minuteLast updated a day ago
Definition
- Type: Struct
- Namespace: Unity.U2D.Physics
- Assembly: UnityEngine.PhysicsCore2DModule
public readonly struct PhysicsWorld.PhysicsGroup
Remarks
Create a group with PhysicsWorld.CreateGroup and assign it with _physicsGroup. Each group is globally unique across all worlds, and a default group has a _groupIndex of zero, meaning no group. Grouping has these limitations: Assigning one group to shapes on more than one body is not supported, and the first and last marking of their events is then unreliable, so several events between the same two groups can each be marked first or last. Marking only applies between two groups, so an event between a grouped shape and a shape with no group is always marked both first and last. When _eventGroupingAllowed is disabled, every event is marked both first and last.
Properties
Property | Description |
|---|---|
| groupIndex | The group index. The value is unique per group; a value of zero means no group. |