Raycast 360 degree check?

if (Physics.Raycast (transform.position, Vector3.left, out hit, 2f)
|| Physics.Raycast (transform.position, Vector3.right, out hit, 2f)
|| Physics.Raycast (transform.position, Vector3.forward, out hit, 2f)
|| Physics.Raycast (transform.position, Vector3.back, out hit, 2f)) {
if (hit.transform.tag == “Enemy”) {
faces [0].renderer.enabled = false;
faces [3].renderer.enabled = true;
} else {
faces [0].renderer.enabled = true;
faces [3].renderer.enabled = false;

So, (obviously) I checked the raycast on up, down, left and right, but then I saw that with this kind of coding, raycast doesn’t watch diagonally.

So, my question is simple (hopefully the answer is as well), is there a way for the raycast to check a full circle around the player/GameObject instead of just doing what I did above (which, from the size of the If statement, I can already guess is pretty wrong, but hey, gotta start from somewhere, right? :slight_smile:


You could try using this