- Home /
Piercing bouncing projectile
So kind of a niche question, is there a way to have something peirce through enemies and damage them with an on trigger enter, and also have bouncing physics? I have it now that the projectile is on a layer that doesn't collide with enemies so that it can pierce them, since otherwise it bounces off of them and messes up the projectiles path. I could make it on the same layer and change the ontrigger to collide but as stated that would make it not pierce the enemy. Any idea how to go about this?
You could have a sub-object childed inside the projectile that is a trigger collider, so that if the projectile passes through the target, the trigger will still get called.
Answer by Navarrox · Feb 22, 2018 at 06:45 AM
I made something similar, but my projectile's bouncing is actually "fake". I made my "bouncer" a trigger collider so he pierced through stuff and everytime he hit something (OnTriggerEnter) i called the OverlapSphere method to check all avaiable targets in range, then i choose one based on distance/last target it collided/other info. After the new target is chosen i just make the projectile LookAt the new target and i add a fixed velocity in that direction (forward). You could do differently and achieve a more "real" bouncing effect, but in my game i need the projectile to behave that way.