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
I have following questions:
- How can I stop collision of ball with these lines?
- 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.