Collision Shape not work in Reality Composer

I’m having issues getting Collision Shapes working in Reality Composer on iPadOS, or with Reality Composer Pro via Xcode on macOS?

I’ve posted a video recorded through my Vision Pro showing the issue.

The project i’m working on is a Dice Rolling application. The dice don’t appear to be working set as Collision Shape=Automatic, which I assume takes into account the actual silhouette of the shape.

https://youtu.be/upPtQY4QOAk?si=yyx6rbSSmVkLxBLg

They also don’t rest on their face when they land.

Anyone experience this type of behavior and found a solution? I’m currently doing this with Reality Composer, but most likely will also be wanting to get it to work properly in Reality Composer Pro as well.

Thx!

Answered by in 817865022

From the documentation on Reality Composer, it reads:

Collision Shape. Used when RealityKit performs physics simulations on the object. Because physics calculations for complex shapes are computationally expensive, RealityKit uses a simplified shape like a box or sphere instead of the object’s actual shape when doing physics calculations. You can select Automatic to let RealityKit choose a collision shape, or you can manually select the shape that will give the behavior you want

In Reality Composer, the automatic mode will choose between one of these two representative shapes for you, but will not use the convex mesh itself.

To use a custom collision shape, you'd need to create your own ShapeResource from a given MeshResource. See https://developer.apple.com/documentation/realitykit/shaperesource/generateconvex(from:)-53jm9

and replace the CollisionComponent that Reality Composer puts on your object with the new one created from your custom shape.

See: https://developer.apple.com/documentation/realitykit/collisioncomponent

This requires some familiarity with the RealityKit API / Xcode / Swift

Here's a quick Maya dynamics test showing what I'm trying to achieve with either Reality Composer, Reality Composer Pro, or both. :)

https://youtu.be/l-T3DkCMRD8

Trying to figure this out - imported the dice model into Reality Composer Pro, and of the three options, neither will work with this particular model.

The next obvious question is, how do we assign a custom mesh (ideally, the original mesh, or a low-res equivalent) with collision component to the mesh with dynamics?

From the documentation on Reality Composer, it reads:

Collision Shape. Used when RealityKit performs physics simulations on the object. Because physics calculations for complex shapes are computationally expensive, RealityKit uses a simplified shape like a box or sphere instead of the object’s actual shape when doing physics calculations. You can select Automatic to let RealityKit choose a collision shape, or you can manually select the shape that will give the behavior you want

In Reality Composer, the automatic mode will choose between one of these two representative shapes for you, but will not use the convex mesh itself.

To use a custom collision shape, you'd need to create your own ShapeResource from a given MeshResource. See https://developer.apple.com/documentation/realitykit/shaperesource/generateconvex(from:)-53jm9

and replace the CollisionComponent that Reality Composer puts on your object with the new one created from your custom shape.

See: https://developer.apple.com/documentation/realitykit/collisioncomponent

This requires some familiarity with the RealityKit API / Xcode / Swift

Thanks for the response as I have also been wondering about this. So follow up question, how can I create a MeshResource from a USDz?

Or is that even possible to do? I have seen some people say that you would need to figure out the actual points and have them in a matrix or hashmap to create the MeshResource.

Accepted Answer

You'll like go from USDZ to Entity which contains a MeshResource when you load/init the USDZ file.

Given that you're working with dice games have you considered TabletopKit?

Yes we have. But as far as I am aware TabletopKit only works on VisionOS and is not available for use on iOS or iPad. Which are the other platforms we would like to target.

Collision Shape not work in Reality Composer
 
 
Q