简体   繁体   English

SceneKit两个节点不冲突

[英]SceneKit two nodes are not colliding

I have two SCNNodes that are Kinematic and aren't colliding, I've set the contactDelegate and the physics bodies are scaled correctly. 我有两个运动学且不会碰撞的SCNNode,我已经设置了contactDelegate,并且物理体已正确缩放。 I can see that the objects and physics bodies are colliding when I debug the app. 调试应用程序时,我可以看到物体和物理物体正在碰撞。

One of the bodies is a child node to a parent node that moves around the scene, while the other body is a physicsBody for a node that does not move 实体中的一个是在场景中移动的父节点的子节点,而另一个实体是不移动的节点的PhysicalBody

    let aShape = SCNBox(width: 1, height: 1, length: 15, chamferRadius: 0)

    let aNode = SCNNode(geometry: aShape)
    aNode.position = SCNVector3(0,2,10)
    aNode.physicsBody = SCNPhysicsBody(type: .kinematic, shape: SCNPhysicsShape(geometry: aShape, options: [SCNPhysicsShape.Option.scale : 0.02]))
    aNode.physicsBody?.isAffectedByGravity = false
    aNode.physicsBody?.allowsResting = false

    pNode?.addChildNode(aNode)
    aNode.physicsBody?.categoryBitMask = 4
    aNode.physicsBody?.contactTestBitMask = 8
    aNode.physicsBody?.collisionBitMask = 8

阅读后( SceneKit:如何检测碰撞而不会发生碰撞 ),我将两个节点都设置为具有静态物理体,并且可以正常工作:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM