我的球有一个动态的物理身体,飞机静止,目标是运动学.我为每个SCNNode设置了categoryBitMask和contactTestBitMask.
当我将球射向球门时,有时球会反弹并且表现得如预期的那样,但有时候球会穿过球门并穿过它.
我还指定了SCNPhysicsContactDelegate,并且当球再次反弹时触发了didBeginContact,但是当球越过它时,则不会调用该方法.
你知道会发生什么吗?
谢谢!
解决方法
您需要一个collisionBitMask实例属性,该属性定义哪些类别的物理实体可以与此物理实体发生冲突.
var collisionBitMask: Int { get set }
When two physics bodies contact each other,a collision may occur. SceneKit compares the body’s collision mask to the other body’s category mask by performing a bitwise AND operation. If the result is a nonzero value,then the body is affected by the collision. Each body independently chooses whether it wants to be affected by the other body. For example,you might choose to avoid collision calculations that would make negligible changes to a body’s velocity.
The default value isall
(a bit mask whose every bit is enabled),specifying that the body will collide with bodies of all other categories.
static var all: SCNPhysicsCollisionCategory { get }
all
is defaultType Property
for a physics body’scollisionBitMask
property.