1

Does anyone know how I can detect when an SKEmitterNode particle makes contact with a SKNode in the SKScene?

I want to apply a little force to the SKNode when a particle makes contact with it for a 2D game I'm creating.

sangony
  • 11,636
  • 4
  • 39
  • 55
SamoanProgrammer
  • 954
  • 4
  • 13
  • 27

1 Answers1

1

You can't. You can't get the location, size and other properties of individual particles.

The essence of a particle system is that its particles are minimalistic and under full control of the particle system. Hence you don't normally get any access to individual particles in a game engine, mainly because it wouldn't make sense to do so.

There can be specialized particle emitters built on regular sprites where you have access to particles and where particles can have physics bodies. Solutions exist for other engines but I'm not aware of one that works with Sprite Kit. These are always slower than regular particle emitters, especially with physics enabled, forcing you to use a lot less particles to begin with.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Yep, I've read that about the SKEmitterNode where you can't have a physic body and what not, however I've designed a game which uses the SKEmitterNode to give an effect of "watering the garden with a hose" so the particles basically form a uniform "arc" type shape, and if an SKNode intersects on this "arc" then I want some force to be applied to the SKNode. I guess I'll just have to somehow calculate the arc shape based on the properties I have applied to the SKEmitterNode and if my SKNode object intersects with that, then apply the force. – SamoanProgrammer May 21 '14 at 11:43
  • Typically devs would "shoot" invisible nodes with physics bodies attached, forming the arc. Then when you are satisfied with how the nodes move, you'd design a particle emitter that closely matches the movement of the (now invisible) bodies. Form (graphics) follows function (gameplay). ;) (AAA developers sometimes have this backwards.) – CodeSmile May 21 '14 at 11:55