sprite-kitsknodeskemitternode

SKEmitterNode tied to a moving SKNode


I am attempting to move a SKEmitterNode to follow a bullet in my game to give it a trailing effect however, no matter which way I attempt to implement this, it doesn't seem to work how I want it to and I'm at a loss for how to make this.

I have attempted to add the emitter to my main scene and manually moved the node a few times per second but it ends up not leaving a trail and keeping all the particles in one place like this: enter image description here

Next I attempted to set the target node, however when I do this the trail goes for a bit then stops rather than following the bullet like it's supposed to. It also rotates and distorts from the rotation of the projectile like shown here: enter image description here

For reference of the type of effect I'm looking for: enter image description here


Solution

  • You should populate the targetNode property of your emitter with a node that is not moving like the scene.

    emitterNode.targetNode = self // where self is the current scene