<!--
{
  "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/init(rawValue:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation14CollisionGroupV8rawValueACs6UInt32V_tcfc"
  },
  "title" : "init(rawValue:)"
}
-->

# init(rawValue:)

Creates a collision group from a raw value.

```
init(rawValue: UInt32)
```

## Parameters

`rawValue`

The raw value of the option set to create. Each bit of
rawValue potentially represents an element of the option set, though raw
values may include bits that are not defined as distinct values of the
OptionSet type.

## Discussion

This initializer succeeds even if the value passed as `rawValue`
exceeds the static properties declared as part of the option set.
Usually, you will want to create each collision groups setting a
different bit flag for each value, so that multiple individual groups
can be combined using
<doc://com.apple.documentation/documentation/Swift/OptionSet> methods.

Here is an example of creating four collision groups using different
bitflag values for each one.

```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)
```

---

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)