Swift: How to set size of particle effects with SCNParticleSystem?

1.8k Views Asked by At

I have simple ARKit app (using SceneKit) with cubes floating in space that I am shooting with other objects. I created .scnp file with Fire as a template and customized it to sort of look like explosion.

Everything looks good and works on collision, but my whole particle effect takes whole screen. I tried every property available on the .scnp file but the size is still enormous.

How can I set the effect area size? For example to be slighty bigger than my cubes (with width 0.1 meters).

This is how run the explosion:

let fire = SCNParticleSystem(named: "explosion.scnp", inDirectory: nil)

contactNode.addParticleSystem(fire!)

contactNode is my target cube.

1

There are 1 best solutions below

2
On

The particle system property you’re looking for is particleSize. (There’s a control for setting that property in the Xcode particle system GUI editor, but I forget what it’s labeled...)

The docs for that property say:

The rendered size, in units of the scene’s world coordinate space, of the particle image.

In ARKit, scene units are the same as real-world meters. So while a particle size of, say, 10x10 might make sense in some arbitrary scene, in AR that makes each particle the size of a house. You probably want values somewhere in the scale of millimeters to centimeters (0.001 - 0.01).