I'm doing a game with SceneKit for which the size of the whole game can change, i.e. the size of the reference node (GameRootNode) to which all nodes are linked can change, then all nodes size change accordingly when it happens.
When it comes to particle system, it is getting tricky. So far I had to do a particle system for each extreme of the size range the game can have, and play with the properties of the particle system to adjust the effect. The result is not good.
So I have tried to scale the particle system with 2 approaches :
attach the
BulletNode
to theGameRootNode
, attach the particle system to theBulletNode
then scale theGameRootNode
(as described below)scale the
GameRootNode
, create theBulletNode
, attach the particle system to theBulletNode
then scale theBulletNode
to the same scale than theGameRootNode
In both cases, the particle system stays with its original size (i.e. the one defined in the SceneKit editor)
Is there a way to scale particle system?
GameRootNode = SCNNode()
let Sequence = SCNAction.sequence([SCNAction.scale(to: VCOfScene.VCPlayAR.ScalingFactor, duration: 0),
SCNAction.move(to: SCNVector3.init(-Float(kNbColonnesLevel) / 2 * Float(VCOfScene.VCPlayAR.ScalingFactor),
0,
-Float(kNbLignesLevel) / 2 * Float(VCOfScene.VCPlayAR.ScalingFactor)),
duration: 0)])
GameRootNode.runAction(Sequence)
BulletNode = SCNNode(geometry: Level3D.Bullet.geometry)
BulletNode.position = Position.PositionToVector()
BulletNode.name = ProjectileImageName + String(ProjectileID)
let BulletShape = SCNParticleSystem(named: "Fireball.scnp", inDirectory: nil)!
BulletShape.emittingDirection = DirectionBullet
BulletShape.particleColor = Character.Color
BulletNode.addParticleSystem(BulletShape)
GameRootNode.addChildNode(BulletNode)
GameRootNode.runAction(Sequence)