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 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.
Particle System moved to Scene Kit Scene File as a library object:

While creating a new file, select SceneKit SceneFile. Edit the suffix to .scnp, and everything is OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With