Advertisement

Collision physics error

Started by April 02, 2018 06:11 AM
0 comments, last by Octane_Test 6 years, 5 months ago

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

table.thumb.png.1274fc4975eb2986a7465d9379fb575c.png

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.

This topic is closed to new replies.

Advertisement