How would I go about fixing "Scene::raycastClosestShape: The maximum distance must be greater than zero!"?

I’m new to Unity (and I’m learning C sharp).
I have not edited any code. I used the first person prefab in the Standard Assets.
I have searched for a fix but couldn’t find one.

You should post your code, in particular code containing Physics.Raycast

I just encountered the error myself, my Physics.Raycast was missing distance argument, but had a layer mask, so it only threw error sometimes. Depending on what layers where selected.

More details here Unity - Scripting API: Physics.Raycast
To me it looks like the documentation code on the last examples are wrong.

This format when using LayerMask does work for me

	if (Input.GetMouseButtonUp(0))
	{
		RaycastHit hit;
		Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		if (Physics.Raycast(ray, out hit, 100f, unitSelectionMask))
		{
			Debug.Log ("Selecting "+hit.transform.name);
		}
	}

Necroing this old question since it was top result when searching for the error.

I know this is a post from last year, but in case anyone else has this problem as I have, I worked my error out with a little trial and error. The problem was not in the script for me, it was in the Unity editor. On some forums I’ve noticed people saying that their camera had a lens flare which once they took off, the error disappeared for them

For me it was my model: My Animator>Update Mode was set to normal, I changed it to Update Physics, and the error disappeared. I’m not saying this will be your solution, but it could point someone in the right direction. I hope this helps future people searching for answer with regards to this error!