Particle and node collision detection in SceneKit
I have several nodes with kinematic phyisicsBodyType and I want it to interact with some System particles, and by that I mean I want to detect collision and execute some code at the moment when the node collides with a nay particle of particles. I found a way by adding an event handler, but I'm not really sure how to use it ( method link here ).
Can someone explain to me how I can use this event handler (it would be preferable to explain it to me in Swift), otherwise can you give me another idea?
source to share
In the end it was very simple. First, you must assign the node array to colliderNodes
the particle system property . After that, the code in swift looks something like this:
particleSystem.handleEvent(SCNParticleEvent.Collision, forPropierties:[SCNParticlePropertyContactPoint], withBlock: {
(data: UnsabeMutablePointer<UnsafeMutablePointer<Void>>, dataStride: UnsafeMutablePointer<Int>, indicies: UnsafeMutablePointer<UInt32>, count:Int) in
//code on detection collision goes here
})
Each parameter is briefly explained in the apple documentation .
source to share