Skip to content

Instantly share code, notes, and snippets.

@kpavlovsky
Created June 24, 2018 21:37
Show Gist options
  • Save kpavlovsky/835b256b013e9dd0539abd3099fb6dc0 to your computer and use it in GitHub Desktop.
Save kpavlovsky/835b256b013e9dd0539abd3099fb6dc0 to your computer and use it in GitHub Desktop.
bool checkSeesEnemy(){
int layerMask = 1 << 8;
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.TransformDirection (Vector3.forward), out hit, see_distance, layerMask)) {
Debug.DrawRay(transform.position, transform.TransformDirection (Vector3.forward) * hit.distance, Color.yellow);
Debug.Log("Did Hit");
return true;
} else {
Debug.DrawRay(transform.position, transform.TransformDirection (Vector3.forward) *1000, Color.white);
Debug.Log("Did not Hit");
return false;
}
}
bool checkObstacleAhead(){
int layerMask = 1 << 9;
RaycastHit hit;
if (Physics.Raycast(transform.position, transform.TransformDirection (Vector3.forward), out hit, see_distance, layerMask)) {
Debug.DrawRay(transform.position, transform.TransformDirection (Vector3.forward) * hit.distance, Color.yellow);
Debug.Log("Did Hit");
return true;
} else {
Debug.DrawRay(transform.position, transform.TransformDirection (Vector3.forward) *1000, Color.white);
Debug.Log("Did not Hit");
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment