无法使用类别位掩码阻止物理场与粒子系统交互

Can't prevent physics field from interacting with particle system using category bit mask

我想将具有相应场的多个粒子系统放置到一个场景中并在它们之间切换。这些场应该只与特定的粒子系统相互作用。我无法使用 Xcode SceneKit 文档生成器这样做。

根据 Apple 文档:

To determine whether a field affects a physics body, SceneKit performs a bitwise AND operation on the field’s category bit mask and the body’s categoryBitMask property. If the result is a nonzero value, SceneKit computes and applies the force of the field on the body. To determine whether a field affects the particles spawned by an SCNParticleSystem object, SceneKit performs the same check using the categoryBitMask property of the node containing the particle system.

Use this property to create fields which affect only certain bodies in your scene. Reducing the number of bodies affected by fields can also improve simulation performance.

我创建了一个简单的场景文件,其中包含:

不管我将类别位掩码设置成什么。物理场总是与粒子系统相互作用。我还尝试在 Playground 中以编程方式将位掩码设置为一个单独的文件,其中包含 3 个粒子系统,每个系统有一个字段,但没有成功。使用:

let effect1Mask = 0x1 << 1
let effect2Mask = 0x1 << 2
let effect3Mask = 0x1 << 3

我发现类别位掩码无法在场景图生成器中的物理场上设置,它没有公开。它必须以编程方式设置。我在物理场节点上设置了遮罩,因此它不起作用的原因。