0
\$\begingroup\$

I am working on a game developed using Scenekit (iOS). I am facing some strange issues with collision physics.

I have added one 3D table (with a hole at its center) to the scene. I am setting physics shape of this 3D model using following code:

SCNBox* tableBody = [SCNBox boxWithWidth:(5*golf.scale.x) height:(0.5*golf.scale.x) length:(9*golf.scale.x) chamferRadius:0];

table.geometry = tableBody; //table geometry

//physics shape scale
NSValue *shapeScale = [NSValue valueWithSCNVector3:SCNVector3Make(table.scale.x, table.scale.y, table.scale.z)];

//physics shape options
NSDictionary *shapeOptions = [NSDictionary dictionaryWithObjectsAndKeys:shapeScale,SCNPhysicsShapeScaleKey,SCNPhysicsShapeTypeConcavePolyhedron,SCNPhysicsShapeTypeKey, nil];

//physics body
table.physicsBody = [SCNPhysicsBody bodyWithType:SCNPhysicsBodyTypeStatic shape: [SCNPhysicsShape shapeWithNode:table  options:shapeOptions]];

I am adding one 3D ball on top of this table.

Issue: The Ball collides with 3D table mesh triangles and changes directions

Image showing 3D table's physics shape: enter image description here

I have following questions:

  1. How can I stop collision of ball with these lines?
  2. Are there any modification to the physics can be done? I want the hole to be part of the physics shape so that the ball can fall into the hole.

I would appreciate any suggestions and thoughts on this topic. Thank you.

\$\endgroup\$
  • \$\begingroup\$ I'm running into a similar issue and was wondering if you found a solution. Thanks \$\endgroup\$ – StarLord Jul 9 '18 at 20:57
  • \$\begingroup\$ This behavior is expected with mesh colliders. Simply collider shape to avoid this issue. \$\endgroup\$ – Nimesh Chandramaniya Jul 11 '18 at 2:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.