- Home /
use OnParticleCollision(GameObject)for AOE spell/magic creation problem
HI: I'm trying to use particle effect as a spell/magic to attack enemies, by using OnParticleCollision(GameObject)method in script. I found that it works just fine when i implemented it to attack single enemy gameobject, but when i tried to apply it to create an AOE spell, it didn't work, it applied damage to only one enemy in the attack area randomly. Is there any possible way to make particle collision apply damage to multiple targets within the spell attack range? is OnParticleCollision function too expensive for an spell/magic attack? Is physic.overlapsphyere a better solution? Is there any better method to implement AOE damage effect? Thank you!
Answer by TheSOULDev · Aug 04, 2017 at 03:41 PM
If your attack is AoE, why are you using ParticleCollision? I mean I get that it is more precise, but I don't think it's worth using over a single collider bound to your character. Any kind of physics is very expensive, I can only imagine something that checks for collision of innumerable small bodies. Now unless that AoE attack is very high precision (like, involves stacking hits or something like that), it would be better to just use a circle or sphere collider. If you want to optimize it even further and need a sphere collider, you don't even need to use colliders - you could just check if the distance between the center of the spell to the enemy is smaller than the distance between the center of the spell and its outer edge.
the spell i created is Irregular shape fire, the effect is very good when the fire spell hit an enemy, its shape changes, and yes ,it is more precise. But you are right, it is not worthy, i think i will go the overlapsphyere method. thank you.
Your answer
Follow this Question
Related Questions
Attacking enemy script problem 0 Answers
How to make a Homing Attack like in Sonic the HedgeHog? 2 Answers
How to give reference to scripts added dynamically? 2 Answers
Applying Damage 5 Answers
Character Animation Assistance 1 Answer