- Home /
What kind of datatype is a CollisionEvent?
On this page in the manual, it says to pass a data type "CollisionEvent[]" to ParticleSystem.GetCollisionEvents, but since that isn't a real data type, what am i supposed to pass? An array of "Collision" is throwing me error "CS1502 ...some invalid arguments"
Thanks! Here is the code i'm working on:
 private Collision[] collisions;
 void OnParticleCollision (GameObject particle){
 //count the collisions
     collisions = new Collision[particle.particleSystem.safeCollisionEventSize];
     temperature += particle.particleSystem.GetCollisionEvents(gameObject,collisions) / 10 * heatingRate;
 }
     
Answer by SmartCarrion · Aug 07, 2013 at 09:51 AM
I found the answer, I needed to refer to it as a ParticleSystem.CollisionEvent[] not just a CollisionEvent[] or Collision[].
Thanks!
Answer by andrew-lukasik · Oct 12, 2013 at 10:41 PM
I just lost few hours to make this little thing work so I presume somebody would find this simple code useful around this topic:
 void OnParticleCollision (GameObject other) {
     ParticleSystem.CollisionEvent[] collisionEvents = new ParticleSystem.CollisionEvent[particleSystemComponent.safeCollisionEventSize];
     particleSystemComponent.GetCollisionEvents (other,collisionEvents);
     foreach (ParticleSystem.CollisionEvent item in collisionEvents) {
         GameObject hitmark = Instantiate (fx_Hit, item.intersection, Quaternion.identity) as GameObject;
         if (other.rigidbody) hitmark.transform.parent = other.transform;
     }
 }
In my case the problem was that item.intersection kept giving me vec3(0,0,0) because as first parameter of particleSystemComponent.GetCollisionEvents(other,collisionEvents) I placed "gameObject" not "other". It confuses me a bit still.
Your answer
 
 
             Follow this Question
Related Questions
Emitting Particles on Collision 0 Answers
Emit Particle when the parent gets collision 2 Answers
How to access particle collision locations 2 Answers
Using Particles with Collision 2 Answers
Locking particle axis? 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                