Combat system hard time

Hello =)

Im having trouble with my combat system , I made one simple before where it just casted a raycast and it worked , But now i noticed it was kinda buggy , and you could even hit yourself sometimes .
Well basicly I want to find all objects in an arc infront of me and send the damage input , yet i cant figure out how to do it :confused:
(Im a java script coder)

Thanks in advance , Utaelilya =)

Anyone?

You should check distance and dot product between your objects to implement an arc-style damage.

to be more precise :
get distance between your 2 objects.
get dot product between the front vector of your โ€œweaponโ€ and the weapon-to-object direction vector.

Do something by testing these 2 values.
(for example, apply damage if dotproduct > 0 and distance <10)
โ€ฆ

Thanks for replying , I used

    var hit : RaycastHit;
    var p1 : Vector3 = transform.position+Vector3.forward;
    var p2 : Vector3 = p1 + Vector3.up * 1+Vector3.forward*3;
	
    if (Physics.CapsuleCast (p1, p2, 1, transform.forward, hit, 10)) 
	{
			var settingsArray = new String[2];
			settingsArray[0]=damage+"";
			settingsArray[1]=localPlayerName;
			hit.collider.SendMessage("ApplyDamage", settingsArray, SendMessageOptions.DontRequireReceiver);
    }

Now its to make it perfect C: