gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 11:10:37 25 4
gpt4 key购买 nike

我想将具有相应场的多个粒子系统放置到一个场景中并在它们之间切换。这些场应该只与特定的粒子系统相互作用。我无法使用 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.

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

  • 线性重力场。它的类别位掩码在节点检查器中设置为 2。
  • 一个节点。它的类别位掩码在节点检查器中设置为 4。
  • 一个球形粒子系统,位于上述节点内。受物理场影响选项已选中。类别位掩码在节点检查器中保留为 1。

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

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

最佳答案

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

关于ios - 使用类别位掩码无法阻止物理场与粒子系统相互作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52211690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com