How to create accurate CollisionShapes for my 3D .USDZ model?

This is how my model looks like and it's collision shapes (pink color).

My problem with this is that when I try to tap on the bottommost part of my model (the circle), I can't do that, because the uppermost part of the model's CollisionShape is in the way.

This is how i tried to create an accurate collisionShape for my model:

@objc private func placeObject() {
     
    let entity = try! Entity.load(named: "Laryngeal")
    let geom = entity.findEntity(named: "Geom")
     
    for children in geom!.children {
      let childModelEntity = children as! ModelEntity
      childModelEntity.collision = CollisionComponent(shapes: [ShapeResource.generateConvex(from: childModelEntity.model!.mesh)])
    }
     
    let modelEntity = ModelEntity()
    modelEntity.addChild(entity)
     
    let anchorEntity = AnchorEntity(plane: .horizontal)
    anchorEntity.addChild(modelEntity)

    arView.installGestures([.all],for: modelEntity)

    arView.scene.addAnchor(anchorEntity)
     
  }

So my question is, how can i create the most accurate collisionShape which perfectly fits my model?

Post not yet marked as solved Up vote post of Pistifeju Down vote post of Pistifeju
733 views
  • How do you visualize the generated collision shapes?

Add a Comment

Replies

Have you tried importing your model through Reality Composer? There you can set collision shapes, maybe that would help…