swiftxcodescenekitarkitparticle-system

SceneKit – How to make self defined particle effect in Xcode 13?


I am trying to mock an explosion particle effect in xcode 13 as below style

enter image description here

because there is no .scnp file I can use in xcode 13, I tried to use below code to complete,

let particleSystem = SCNParticleSystem()
particleSystem.birthRate = 800
particleSystem.loops = false
particleSystem.blendMode = .alpha         
particleSystem.particleSize = 0.030
particleSystem.emitterShape = SCNSphere(radius: 0.9)
particleSystem.particleColor = .yellow
particleSystem.particleLifeSpan = 0.5
particleSystem.particleImage = "art.scnassets/spark.png"
particleSystem.particleColorVariation = SCNVector4(0.5, 0.5, 0.5, 0)

But the result is not expected.

Can anyone help to give any instruction how to do that?


Solution

  • To setup particles in UI, choose SceneKit's .scn file in Navigator panel and then add a Particle System object from Xcode 13 library pressing + button (instead of a deprecated .scnp file):

    enter image description here