実装メモ:ParticleEmitterComponent でパーティクルを Entity 自身に吸収させる

パーティクル演出は基本的に放出されるようなイメージがあるが、visionOS の ParticleEmitterComponent では内向きに集約させることもできるのでメモ。

mainEmitter.attractionCenter に吸収先の座標を指定すればよく、emitterShapeSize を Entity のサイズよりも大きく指定した上で、エミッターを持つ Entity 中心座標を指定すれば、自分自身にパーティクルを吸収させることができる。

var p = entity.components[ParticleEmitterComponent.self]!
p.emitterShape = .sphere
p.emitterShapeSize = .init(x: 0.1, y: 0.1, z: 0.1)
p.fieldSimulationSpace = .local
p.mainEmitter.attractionCenter = entity.position(relativeTo: entity)

entity.components[ParticleEmitterComponent.self] = p

検証環境:visionOS 26.0.1