Skip to content

Instantly share code, notes, and snippets.

@alexgladd
Last active October 10, 2015 14:38
Show Gist options
  • Save alexgladd/3e5c581885fd5b28e972 to your computer and use it in GitHub Desktop.
Save alexgladd/3e5c581885fd5b28e972 to your computer and use it in GitHub Desktop.
Raycast for Attacker detection
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