For some reason, the following code never detects a raycast. I’ve checked the debug lines, and the other object is clearly being hit and has a collider. Additionally, the raycast is spawned from outside of the collider. Why isn’t it working?
RaycastHit Hit;
Debug.Log("Shooting");
transform.LookAt(player, Vector3.up);
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
Debug.DrawLine(Raycaster.transform.position/* + new Vector3(horzOffset, heightOffset, 0)*/, Armature.transform.forward * angleMult, Color.blue);
if (Physics.Raycast(Raycaster.transform.position/* + new Vector3(horzOffset, heightOffset, 0)*/, Armature.transform.forward * angleMult, out Hit, Range)) {
Debug.Log(Hit.transform.name);
Hit.transform.SendMessage("rayHit", myTeam);
}
alreadyAttacked = true;
Invoke(nameof(ResetAttack), timeBetweenAttacks);