- Home /
How do I destroy all enemy game objects with a bomb?
Hello, Im new to coding so bare with me. I want to destroy all enemy game objects that are in the blast radius of a bomb. The simpler the better. Thank you so much for helping!
This is a very common question. What have you searched for/tried, post the code. If you are at step 0, take a look at doc for SphereCastAll and see if that works for you.
Answer by UnitedCoders · Jan 18, 2018 at 06:14 AM
Instatntiate a sphere gameobject at your bomb position, sphere must have rigidbody and collider and attach the script on this object, disable your mesh component. Script contain
void OnTriggerEnter(Collider other) { if(other.gameObject.tag=="Enemy") { Destroy(other.gameObject); } }
In the Start() write some code which scale your gameObject from (0,0,0) to your desired scale(e.g 3,3,3) .
@PaulSullivan87
you can ask further if you have any query.
Thank you so much this solved my problem! I really appreciate it!
Your answer
Follow this Question
Related Questions
timed bomb, explosion detection 2 Answers
Grenade Damage in Radius 2 Answers
OverlapSphere not causing damage? - Solved 2 Answers
How to confirm the vertex of a mesh that mouse in and change its texture 0 Answers