//ScreenPointToRay was created by Jonathan Weimberger //This is my way of creating a debugRay to view the raycast //Jonathan liked using the ray, it may be easier to use a //startTransform.pos and finishTransform.pos instead...just saying //Lecture 214 //draw gun raycast Ray debugRay = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2.0f, Screen.height / 2.0f, 0.0f)); Debug.DrawRay(debugRay.origin, debugRay.direction * _debugRayLength, Color.red); //**** OR **** Ray debugRay = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.0f)); Debug.DrawRay(debugRay.origin, debugRay.direction * _debugRayLength, Color.red);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter