RealityKit Mesh with USDZ 3D Model

Hello, I'm adding a CollisionComponent to an entity in RealityView. CollisionComponent requires that a Mesh must be provided as a reference for collision detection. However, in order to achieve more accurate detection, I hope that this Mesh resource is a geometric shape of a USDZ model. Is there any way to make it happen? Thank you!

Answered by DTS Engineer in 850553022

Hello @lijiaxu,

CollisionComponent requires a ShapeResource, you can generate a ShapeResource from a static mesh using generateStaticMesh(from:).

You can get the MeshResource of a ModelComponent by accessing the mesh.

--Greg

Accepted Answer

Hello @lijiaxu,

CollisionComponent requires a ShapeResource, you can generate a ShapeResource from a static mesh using generateStaticMesh(from:).

You can get the MeshResource of a ModelComponent by accessing the mesh.

--Greg

@lijiaxu

Adding to what Greg said, I recommend reviewing the section Prepare assets for gameplay for our WWDC25 sample Petite Asteroids. This article describes the process of loading complex geometry and using it to generate a collision mesh.

Thank you for your question!

RealityKit Mesh with USDZ 3D Model
 
 
Q