Hello,
I’m currently working on Weapons in my project, and I’m trying to create damage zone for a melee weapon ( a sword ) used when the player is calling the attack method of his weapon.
So, basically I want to create an invisible zone area ( which will be represented by an animation later ) for the weapon damage zone … then every GameObject in this area with the “Enemy” tag will lose some health points.
I’ve never worked on this kind of thing, so I’m kinda lost.
I know I could use Ray to do this, but :
(1) I don’t know how to link every to create a zone;
(2) I don’t know how I could gather every GameObject in this area;
Any idea ? 
1 Like
You’d create this zone just by adding some sort of collider (probably a BoxCollider or a SphereCollider) to your weapon.
And you’ll detect hits with it through the standard collision-detection methods (google is your friend).
Oh, yes, I should have detailled my question a little bit more.
So, to be more specific, I’m looking for a way to build a boxCollider with angles ( which can be modified ), something like this :

Should I import a triangle model then use it to make the collider with it ?
I think I see. You have a weapon with a wide fan-shaped damage area, and you want to find all targets in that area so you can damage them.
I would do this in two steps: get all the targets within a certain radius (lots of ways to do that), and then checking each of those to see if they’re in the hit zone. That’s pretty easily done by finding the angle between the aim direction (center of the fan) and the target, probably in the XZ plane if this is a 3D game.
1 Like
Thanks Joe… this page is great… (yeah… I’m still on the Space Shooter tutorial… I learn enough to do some art,then run with it… but this page is exactly what I needed… and it’s free.)… and I finally get that “hello world” joke
1 Like
If you just want to damage them, but not move them, don’t forget to set the collider as a Trigger.
Then, in a script in the collider, puts the OnTriggerEnter collision handler: Unity - Scripting API: Collider.OnTriggerEnter(Collider)
In the case of a sword, I think it could be just a rectangular box collider moving quickly.
This way, the HP numbers would decrease in the correct order, not at the same time.