所以我设计了一个走廊,我想让我的玩家穿过,但我似乎无法让一个物理体为它工作。玩家要么穿过墙壁,要么不能走下走廊,因为它会将物体视为一个巨大的立方体。我如何让物理体绕着物体移动。
let chessPieces = SCNScene(named: "art.scnassets/hallway.dae")
if let knight2 = chessPieces?.rootNode.childNodeWithName("Room", recursively: true) {
knight2.position = SCNVector3Make(150, 30, 0)
knight2.scale = SCNVector3Make(knight2.scale.x * 200, knight2.scale.y * 200, knight2.scale.z * 200)
var nodeScale = NSValue(SCNVector3:SCNVector3Make(200, 200, 200));
var nodeGeometry = knight2.geometry;
var shape = SCNPhysicsShape(geometry: nodeGeometry!, options: [SCNPhysicsShapeScaleKey:nodeScale])
knight2.physicsBody = SCNPhysicsBody(type:SCNPhysicsBodyType.Static, shape: shape)
knight2.physicsBody?.categoryBitMask = rockCategory
knight2.physicsBody?.angularVelocityFactor = SCNVector3Make(0.0,0.0,0.0)
knight2.physicsBody?.collisionBitMask = 3
knight2.name = "Student"
knight2.physicsBody?.mass = 1000
scene?.rootNode.addChildNode(knight2)
}