- Home /
Question by
TauseefCVS · Aug 10, 2016 at 03:14 PM ·
colliderstexturesraycasthittagscollider.raycast
Head shoot and body shoot not working with realistic fps characterDamage
I made a script to headshot and bodyshot but its not working i am using realistic fps and its is not detect the proper raycasthit please help me
public void ApplyDamage (float damage, Vector3 attackDir, Vector3 attackerPos, Transform attacker, bool isPlayer, RaycastHit hit)
{
// Debug.Log (attackDir);
if (hitPoints <= 0.0f) {
return;
}
if (hit.collider.GetType () == typeof(CapsuleCollider)) {
if (hitPoints - damage > 0.0f) {
hitPoints -= damage * damage;
//Debug.Log (hitPoints);
} else {
hitPoints = 0.0f;
}
} else if (hit.collider.gameObject.name == GameObject.FindGameObjectWithTag ("Headshot").gameObject.name) {
Debug.LogWarning ("Working with sphare collder");
if (hitPoints - damage > 0.0f) {
hitPoints -= damage * damage;
Debug.Log (hitPoints);
} else {
hitPoints = 0.0f;
}
Debug.LogWarning (hitPoints);
} attackDir2 = attackDir;
attackerPos2 = attackerPos;
if (hitPoints <= 0.0f) {
Debug.Log ("print die is working");
SendMessage ("Die");//use SendMessage() to allow other script components on this object to detect NPC death
}
}
Comment