Skip to content

Instantly share code, notes, and snippets.

@Ashwinning
Created February 8, 2016 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ashwinning/9b8793246f3cc9147d52 to your computer and use it in GitHub Desktop.
Save Ashwinning/9b8793246f3cc9147d52 to your computer and use it in GitHub Desktop.
Raycast from center : re
	RaycastHit RaycastFromCenter()
	{
		// Determine if we hit anything
		Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));
		RaycastHit hit;
		if (Physics.Raycast (ray, out hit)) 
		{	
			return hit;
		}
		else 
		{
			return null;
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment