- Home /
Two Hitboxes, One parent
Hello i am really irritated and want to detect either a headshot hitbox or a body hitbox on my ai, the problem is it either thinks both of them are the body hitbox or both are the head hitbox. i tryed to get around this by using a script on the headshot box when its hit it initates a headshot event that takes away all of the health from the ai. But instead it dosnt work.
if (Physics.Linecast(previousPos, currentPos, hit, layerMask) && (Time.time-time) > 0.001)
{
switch(hit.transform.tag)
{
case "Target":
AudioSource.PlayClipAtPoint(TargetSound, Camera.main.transform.position);
Instantiate(HoleDecal[0], hit.point + (hit.normal * DecalOffset), Quaternion.LookRotation(hit.normal));
Destroy(gameObject);
break;
case "Zombie":
Debug.LogError("BODY SHOT");
hit.transform.gameObject.GetComponent(Zombie).Health -= DamageToDeal;
Destroy(gameObject);
break;
case "Head":
Debug.LogError("HEAD SHOT");
hit.transform.gameObject.GetComponent(HeadShotDetector).Headshot = true;
Destroy(gameObject);
break;
}
}
My heirarchy is as fallows
AI Eyes ViewCone HeadshotBox Model
The headshot box script works fine, i just dont know whether or not its to do with my code or the engine or the setup im trying to run.
Your answer
Follow this Question
Related Questions
4.6.0 InputField help 1 Answer
Unity C# help for beginners tutorial needed (Urgent) 2 Answers
how to trigger another script in unityscript 1 Answer
Creating a 2D sidescroller, anyone know any sprite sheet tutorials? 1 Answer
I need to create an explosion in front of a charactor controller. 0 Answers