<!--
{
  "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/Entity/generateCollisionShapes(recursive:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation6EntityC23generateCollisionShapes9recursiveySb_tF"
  },
  "title" : "generateCollisionShapes(recursive:)"
}
-->

# generateCollisionShapes(recursive:)

Creates the shape used to detect collisions between two entities that
have collision components.

```
@MainActor @preconcurrency func generateCollisionShapes(recursive: Bool)
```

## Parameters

`recursive`

A Boolean that you set to `true` to also generate the
collision shapes for all descendants of the entity.

## Discussion

Call this method on entities that have a mesh to prepare a shape used for collision
detection. The method stores the shape in the entity’s
[`CollisionComponent`](/documentation/RealityKit/CollisionComponent) instance.

This method has no effect for entities without a mesh. Nevertheless, the
method is defined for all entities so that you can call it on any
entity, and have the calculation propagate recursively to all that
entity’s descendants.

---

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)