我正在 Scene Kit 中开发一个玉米洞游戏,并遇到了一个错误SCNPhysicsShape
和SCNPhysicsBody
摩擦。游戏的棋盘通过.dae
文件加载并设置为SCNPhysicsShapeTypeConcavePolyhedron
. 这允许豆袋从孔中掉下来,但它似乎消除了板上的摩擦。当豆袋碰到板子时,尽管摩擦值为 1.0(豆袋的摩擦值也为 1.0),但它还是会滑落。如果我将板换成SCNPhysicsShapeTypeConvexHull
摩擦力起作用,但豆袋不会从孔中掉下来。
这是我的自定义板初始化:
let geo = nodeWithFile("board.dae").geometry!
geo.materials = [SCNMaterial()]
geo.firstMaterial!.diffuse.contents = "wood_texture.png"
geo.firstMaterial!.diffuse.wrapS = SCNWrapMode.Repeat
geo.firstMaterial!.diffuse.wrapT = SCNWrapMode.Repeat
geo.firstMaterial!.diffuse.mipFilter = SCNFilterMode.Linear
self.geometry = geo
self.position = position
self.rotation = SCNVector4Make(1, 0, 0, -CFloat(degreesToRadians(65.0)))
let shape = SCNPhysicsShape(geometry: geo, options: [SCNPhysicsShapeTypeKey: SCNPhysicsShapeTypeConcavePolyhedron])
self.physicsBody = SCNPhysicsBody(type: .Static, shape: shape)
self.physicsBody!.restitution = 0.0
self.physicsBody!.rollingFriction = 1.0
self.physicsBody!.friction = 1.0
这是豆袋的自定义初始化
let geo = SCNBox(width: 20.0, height: 4.0, length: 20.0, chamferRadius: 5.0)
self.geometry = geo
self.position = position
self.geometry!.firstMaterial!.diffuse.contents = UIColor.blueColor()
let shape = SCNPhysicsShape(geometry: geo, options: [SCNPhysicsShapeTypeKey: SCNPhysicsShapeTypeBoundingBox])
self.physicsBody = SCNPhysicsBody(type: .Dynamic, shape: shape)
self.physicsBody!.restitution = 0.0
self.physicsBody!.rollingFriction = 1.0
self.physicsBody!.friction = 1.0
这些都在子类的类的 init 方法中SCNNode
我的问题是:我怎样才能将板保持为 aConcavePolyhedron
并同时使摩擦起作用?