Last active
December 20, 2015 06:29
-
-
Save estebanpadilla/6086105 to your computer and use it in GitHub Desktop.
Ray cast from object to detecting hit, draws a red line when a hit is detected otherwise draws a green light forward from object.
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
void Update () { | |
RaycastHit hit; | |
Vector3 fwd = transform.TransformDirection(Vector3.forward); | |
if (Physics.Raycast(transform.position, fwd, out hit, 10.0F)){ | |
print("There is something in front of the object!"); | |
Debug.DrawLine(transform.position, hit.collider.gameObject.transform.position, Color.red); | |
} | |
fwd = transform.TransformPoint(Vector3.forward * 4); | |
Debug.DrawLine(transform.position, fwd, Color.green); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment