- Home /
How to make projectile do AOE/Splash Damage (2D)
Hello, I have two objects here, they're very close together to make it look like one board. they each have a polygon collider, and they are children of an empty gameobject with a box collider.
Right now, I have it so that when the box collider gets hit, both boards become kinematic = false. So it looks like it cracks in half lol. Now my questions is, is there a way not to use a parent? and just have the nearest collider or rigidbody become not kinematic? I guess what I'd like to know is if there is anything for "NEAREST" or "Within a certain radius". I would want to have it so, if one board gets hit, the other board will take half damage as well. I will be using this on many object and most will have more than 2 objects attached. I'm currently using this code but it's taking too long to get each object sorted out.
void OnCollisionEnter2D (Collision2D collision) {
if (collision.collider.tag != "Rock")
return;
Destroy(this.collider2D);
gameObject.GetComponentsInChildren<Rigidbody2D>();
rig1.isKinematic = false;
rig2.isKinematic = false;
Thank you in Advance! :)
Answer by cdrandin · Jan 14, 2015 at 03:06 AM
A simple way for AoE type collision could be to use a Sphere which acts as your hit box(sphere). Then to reduce calculation you only do this check when it is within a close enough distance for it to even be touching.
So, hopefully what you want is you have this object be within a certain distance of an object which is tagged as "Destructible" for instance. When the object is in fact colliding, you trigger the corresponding objects DestroyAnimation, which will break in half, etc..
Hopefully, this help. It was hard to understand what you were asking for.
Thanks! That's what I'm going to work on next. It makes a lot of sense!
Your answer
![](https://koobas.hobune.stream/wayback/20220613180336im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I make my gameObject find the nearest object with a specific tag and rotate to look at it? 6 Answers
How could I calculate the distance to recieve the nearest object to the player? 2 Answers
Detect closest reachable point of object 1 Answer
Constantly looking for nearest object 4 Answers
Locking onto enemies with the third person controller 2 Answers