How to add particle trail

When adding a particle emitter in SpriteKit, I want each particle to stay in the same spot instead of moving with the node the particle is coming off of. My node moves, and I want the particle to flow off of the back and float up (as a trail). Not to be stuck dragged behind the node.

Any help?

Im using swift in Xcode.

Accepted Answer

So I did some digging and figured it out. You add a particle emitter file, make it how you want, then add this code to your "override func didMove(to view: SKView)" function. Don't forget to put in your own player (or whatever node you want to attach the particle to), and your own file name in place of "file"!

let emitter = SKEmitterNode(fileNamed: "file.sks")

emitter?.targetNode = self

emitter?.position = CGPoint(x: -70, y: -10)

emitter?.particleSize = CGSize(width: 35, height: 35)

player.addChild(emitter!)

"emitter?.targetNode = self" is what makes the particles stay in the same spot instead of following the node!

How to add particle trail
 
 
Q