<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/CollisionGroup",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14CollisionGroupV"
  },
  "title" : "CollisionGroup"
}
-->

# CollisionGroup

A bitmask used to define the collision group to which an entity belongs.

```
struct CollisionGroup
```

## Overview

Use collision groups along with [`CollisionFilter`](/documentation/RealityKit/CollisionFilter) to define custom
collision properties for entities in your scene and to control which entities
collide with which others. By default, all entities that participate in the physics
simulation collide with all other participating entities. There are times,
however, when you need certain entities to not collide with certain other
entities, and that’s where collision groups and filters come into play.

Create individual collision groups using raw bit flag values, like this:

```swift
let redGroup = CollisionGroup(rawValue: 1 << 0)
let blueGroup = CollisionGroup(rawValue: 1 << 1)
let greenGroup = CollisionGroup(rawValue: 1 << 2)
let yellowGroup = CollisionGroup(rawValue: 1 << 3)
```

Because [`CollisionGroup`](/documentation/RealityKit/CollisionGroup) conforms to
<doc://com.apple.documentation/documentation/Swift/OptionSet>, this allows
you to create aggregate groups that encompass multiple individual collision
groups, like so:

```swift
let blueAndRedGroup = redGroup.union(blueGroup)
let greenAndYellowGroup = greenGroup.union(yellowGroup)
```

You can also define groups that have all entities except those in specific
groups. In a game, for example, you might want to turn off collisions
between members of the same team or between pieces owned by the same player.
This is what creating that kind of filter would look like:

```swift
let allButRedGroup = CollisionGroup.all.subtracting(redGroup)
```

Collision groups aren’t assigned directly to entities. Instead, you create a
[`CollisionFilter`](/documentation/RealityKit/CollisionFilter) for the group, and then assign that filter to all the
entities you wish to include in its group. The collision filter’s mask
defines which objects the entities in this group collide with, and all
entities that share the same filter are part of the same collision group.

```swift
let allButRedFilter = CollisionFilter(group: redGroup, mask: allButRedGroup)
redTeamPlayer1.collision?.filter = allButRedFilter
```

## Topics

### Standard collision groups

[`static let `default`: CollisionGroup`](/documentation/RealityKit/CollisionGroup/default)

The default collision group for objects.

[`static let all: CollisionGroup`](/documentation/RealityKit/CollisionGroup/all)

The collision group that represents all groups.

[`static let sceneUnderstanding: CollisionGroup`](/documentation/RealityKit/CollisionGroup/sceneUnderstanding)

The default collision group for scene-understanding meshes.

### Creating a collision group

[`init(rawValue: UInt32)`](/documentation/RealityKit/CollisionGroup/init(rawValue:))

Creates a collision group from a raw value.

## Relationships

### Conforms To

[`ExpressibleByArrayLiteral`](/documentation/Swift/ExpressibleByArrayLiteral)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`OptionSet`](/documentation/Swift/OptionSet)

[`Equatable`](/documentation/Swift/Equatable)

[`SetAlgebra`](/documentation/Swift/SetAlgebra)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)