Search code examples
iosiphonesprite-kitparticles

SKEmitterNode angle issue


I'm experiencing a strange issue when setting the angle of the particle effect programatically.

I have a particle node with a fire effect. If I set the angle as 90 in the editor, the fire shoots straight up, which is what you'd expect. But if I set it with code (setEmissionAngle: 90), it's slanted and looks more like 110 degrees.

I've been scratching my head for hours over this. Any ideas as to what could be causing this?


Solution

  • Quote the documentation for emissionAngle:

    The average initial direction of a particle, expressed as an angle in radians.

    90 radians is a whole bunch of times around the circle and then some. (Where "some" is about 110 degrees.)

    In the Xcode particle system editor UI, you work in degrees and it converts to radians for you behind the scenes. In code, you either need to work in radians or do the conversion yourself.