Scene::raycastAnyShape: The maximum distance must be greater than zero!

Hey Everybody! I have made a little level in unity… looks cool and all… But when I switch to game mode, the following three errors appear over and over:

  • !IsNormalized (dir)
  • !IsNormalized (ray.GetDirection ())
  • Scene::raycastAnyShape: The maximum distance must be greater than zero!

Any idea what this could mean? Thanks in advance!

The post is old but for others:

This 2 messages may be related to a not initialized struct.

!IsNormalized (dir)
!IsNormalized (ray.GetDirection ())

I.E your script may use ray variable without a correct ray creation:

var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);

dir is a vector3? Where do you use it? The istruction tha use ‘dir’ expects a normalizated vector, so you can initialize ‘dir’ correctly or you may normalize it with function Vector3.Normalize

I got same problem when I add Camera, Flare Layer, Lens Flare to a GameObject in scene.
So I fount that the position and rotation of GameObject is not zero, and I set them to zero, errors disappeared.(the scale are 20, 20, 20).

I disabled flare on light that was very close to camera. Fixed.