I’m trying to find all the colliders that would fit into a cross product in front of my player so I can give them damage, but I don’t know how to do that; does anybody have any suggestions?
First 28 seconds.- Player Swings
- Animation Event triggers detect damage for anything in the cross or dot product of the forward vector
- The script passes damage value to the object health script
- All Objects within the damager radius (green radian area) receive a passed event trigger (hit, stun, burn, etc., etc.)
Code So far:
void DetechCollision()
{
Collider[] hit = Physics.OverlapSphere(transform.position, radius, collisionLayer);
if (hit.Length > 0)
{
for (int i = 0; i < hit.Length; i++)
{
if (hit*.gameObject.GetComponent<Enemy>() != null)*
-
{* -
Debug.Log("Contact");*
_ hit*.gameObject.GetComponent().Hit(this.transform);_
_ hit.gameObject.GetComponent().DealDamage(1);
}
}*_
* if (isPlayer)*
* {*
* Vector3 hit_FX_Pos = hit[0].transform.position;
hit_FX_Pos.y += (hit[0].bounds.size.y * .5f);
Instantiate(hit_FX, hit_FX_Pos, Quaternion.identity);
_ }*_
* Debug.Log("You hit " + hit[0].gameObject.name + " with " + this.gameObject.name);*
* gameObject.SetActive(false);*
* }*
}
