How do I make headshots do more damage using raycast?
So I have a zombie, and it is the parent of a head model, just the head is tagged "Head", why doesnt this work? shooting the head should do more damage? Thanks (javascript):
var DamageAmount : int = 5;
var DamageAmountHead : int = 15;
var TargetDistance : float;
var AllowedRange : float = 400;
function Update () {
if (GlobalAmmo.LoadedAmmo >= 1) {
if(Input.GetButtonDown("Fire1")) {
var Shot : RaycastHit;
if (Physics.Raycast (transform.position, transform.TransformDirection(Vector3.forward), Shot)) {
TargetDistance = Shot.distance;
if (TargetDistance <= AllowedRange && (Shot.collider.tag.Equals("Head"))) {
Shot.transform.SendMessage("DeductPoints", DamageAmountHead, SendMessageOptions.DontRequireReceiver);
}
else if (TargetDistance < AllowedRange) {
Shot.transform.SendMessage("DeductPoints", DamageAmount, SendMessageOptions.DontRequireReceiver);
}
}
}
}
}
Comment
Answer by KenjiKyo · Jul 14, 2017 at 03:41 AM
Probably the daycast hits your "zombie" parent object before reaching the "head" object.
Your answer
Follow this Question
Related Questions
Help with photon being used to make a mulitplayer fps 0 Answers
Change color of sprite when hit by raycast [SOLVED] 2 Answers
Raycast over Photon 0 Answers