- Home /
Collision with Particle Systems
Greetings!
I'm making fireballs as particle systems for the player to dodge. What's the best way to handle collision on these particle systems?
create an empty gameObject, then assign collider and rigidbody, and parent at particle system
Answer by GC1983 · Jul 25, 2012 at 01:51 AM
You dont need a rigidbody. Rigidbodies are for physics (gravity).
In the components menu, under Effects -> Legacy Particles, you will find "World Particle Collider". Add that to your emitter object. This will give your particles their own individual colliders.
Then, you add a script you will create OnParticleCollision(). Its just like OnTriggerEnter or OnCollisionEnter, but it will recognize the particle elements.
function OnParticleCollision (collision: GameObject )
{ if(collision.transform.tag == "Player") { Debug.Log("Damage"); } }
Then, from there just adjust it to your liking. You will also have to tinker with the World Particle Collider to your standards.
Hope this helps.
sorry I thinking at the dodgeball, then something to throw
often I'm Confused by English :)
Answer by Endarire · Jul 26, 2012 at 09:39 AM
What is meant by "Player" ?
"Player" is a tag. Typically if you have multiple player characters through different levels, you will tag all of them as "Player" so when scripting a universal function, it will recognize any PC you use ins$$anonymous$$d of just one named one. You can tag whatever object you want with whatever name.
So, in the instance that have made above, collision.transform.tag == "Player" is checking to see if it has collided with any objects that have been tagged with that name.
$$anonymous$$ake sense?