Last active
October 10, 2015 14:38
-
-
Save alexgladd/3e5c581885fd5b28e972 to your computer and use it in GitHub Desktop.
Raycast for Attacker detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool IsAttackerInLane () { | |
RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, Vector2.right); | |
int i = 0; | |
while (i < hits.Length) { | |
if (hits[i].collider && hits[i].collider.GetComponent<Attacker>()) { | |
return true; | |
} | |
i++; | |
} | |
return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment