-1

I have a terrain created from a perlin noise in SceneKit, and now I want to add physics to the terrain. However, simply doing terrain.physicsBody = SCNPhysicsBody(type: .static, shape: nil) results in SceneKit converting the physics shape of the terrain into a convex shape automatically. Now if you put anything onto the terrain, it'll be floating in the air on a plane of the bounding box of the terrain instead of sticking to the ground.

How can I modify the behaviors of SCNPhysicsBody so that it simulates the physics of a terrain?

Neo
  • 11
  • 2

1 Answers1

0

Since SceneKit doesn't have a dedicated Terrain collider nor does it allow you to create custom collider, I solved it by using a concave polyhedron physics shape instead.

node.physicsBody = SCNPhysicsBody(type: .static, shape: SCNPhysicsShape(geometry: geometry, options: [SCNPhysicsShape.Option.type: SCNPhysicsShape.ShapeType.concavePolyhedron]))

Neo
  • 11
  • 2