Unity Debug Raycast | DebugRay Center of Screen

PHOTO EMBED

Wed Jan 27 2021 15:46:44 GMT+0000 (UTC)

Saved by @cotterdev #c#

//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);    
content_copyCOPY