Recently I updated my Xcode to 11.3.1. But while working with SceneKit
, I found that I can't create a particle system file.
- Before
- After
How can I create a particle system in a file now?
Recently I updated my Xcode to 11.3.1. But while working with SceneKit
, I found that I can't create a particle system file.
How can I create a particle system in a file now?
In Xcode 14 / 13 / 12 / 11 you have no preconfigured .scnp
particle system files anymore. Instead, you can use a Particle System
object coming from a Xcode Library (with the same settings in Attributes Inspector as they were in Xcode 10).
If you manually placed a Particle System
from library into SceneKit's Scene graph
you can then retrieve it and setup programmatically. Let's see how it looks like:
let particlesNode = sceneView.scene?.rootNode.childNode(withName: "particles",
recursively: true)
particlesNode?.particleSystems?.first?.isAffectedByGravity = true
particlesNode?.particleSystems?.first?.acceleration.z = 5.0
Or you can easily create a Particle System from scratch using just code:
let particleSystem = SCNParticleSystem()
particleSystem.birthRate = 1000
particleSystem.particleSize = 1.45
particleSystem.particleLifeSpan = 2
particleSystem.particleColor = .yellow
let particlesNode = SCNNode()
particlesNode.addParticleSystem(particleSystem)
sceneView.scene!.rootNode.addChildNode(particlesNode)
.scnz
file containing Particle System.scn
file in Project Navigator (left pane) and choose File – Export....scnz
Or you can create .scnp
file by renaming .scn
– the same way @ycao proposed.
While creating a new file, select SceneKit SceneFile
. Edit the suffix to .scnp
, and everything is OK.
You can also right click inside the scene graph viewport Create > ParticleSystem then adjust the settings as per usual in the properties inspector. Then do the usual stuff as mentioned above in code to retrieve the system, move about, change settings etc.