【发布时间】:2018-10-06 00:53:30
【问题描述】:
我有 2 个简单的节点(2 个球:一个在另一个之上且不接触),每个节点都有一个具有相同特征的物理体。下面是父节点,上面是子节点。
当我对父节点施加力时,两个节点都在移动,但子节点的物理体不移动。我激活了showphysicsshape选项,我看到孩子的physicsbody停留在原来的地方。
我错过了什么吗?
Class Character3DClass: CharacterClass
{
var CharacterNode: SCNNode!
var CenterBody: SCNNode!
func InitChar()
{
InitBodyParentNode()
AddCenterBody()
}
func InitBodyParentNode()
{
CharacterNode.physicsBody = SCNPhysicsBody(type: .dynamic, shape: SCNPhysicsShape(node: CharacterNode, options: [:]))
CharacterNode.physicsBody?.isAffectedByGravity = false
CharacterNode.physicsBody?.mass = 1
CharacterNode.physicsBody?.charge = 0
CharacterNode.physicsBody?.friction = 0
CharacterNode.physicsBody?.rollingFriction = 0
CharacterNode.physicsBody?.restitution = 0
CharacterNode.physicsBody?.damping = 0
CharacterNode.physicsBody?.angularDamping = 0
// Affectation des caractéristiques pour la gestion des collisions
CharacterNode.physicsBody?.categoryBitMask = eNodePhysics.Player.rawValue
CharacterNode.physicsBody?.contactTestBitMask = eNodePhysics.Player.rawValue | eNodePhysics.Ennemy.rawValue
CharacterNode.physicsBody?.collisionBitMask = eNodePhysics.TileBorder.rawValue
}
func AddCenterBody()
{
CenterBody = SCNNode(geometry: Level3D.Dot.geometry)
CenterBody.categoryBitMask = eNodePhysics.PlayerCenter.rawValue
CenterBody.position = SCNVector3.init(0, 3, 0)
CenterBody.scale = SCNVector3.init(0.4, 0.4, 0.4)
CenterBody.physicsBody = SCNPhysicsBody(type: .dynamic, shape: SCNPhysicsShape(geometry: CenterBody.geometry!, options: nil))
CenterBody.physicsBody?.isAffectedByGravity = false
CenterBody.physicsBody?.mass = 1
CenterBody.physicsBody?.charge = 0
CenterBody.physicsBody?.friction = 0
CenterBody.physicsBody?.rollingFriction = 0
CenterBody.physicsBody?.restitution = 0
CenterBody.physicsBody?.damping = 0
CenterBody.physicsBody?.angularDamping = 0
CenterBody.physicsBody?.categoryBitMask = eNodePhysics.PlayerCenter.rawValue
CenterBody.physicsBody?.contactTestBitMask = eNodePhysics.PlayerCenter.rawValue
CenterBody.physicsBody?.collisionBitMask = eNodePhysics.NoValue.rawValue
CharacterNode.addChildNode(CenterBody)
}
}
【问题讨论】:
-
是不是因为你的子节点的Mask和父节点不同?
-
不。尝试使用相同的掩码和相同的问题