- Home /
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!
Have you got any scripts attached to any game objects in your scene and/or do any objects have a raycast component?
I just found the error... I got a "lens flare" attached to the camera... wherever that came from :/... thx anyways and merry christmas ;)
make sure you don't have a negative scale on a gameobject that contains a camera
Answer by giulio-pierucci · Apr 06, 2013 at 07:28 AM
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
Answer by BaoyuMou · Feb 21, 2014 at 06:22 AM
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).
Answer by aeroson · Aug 04, 2014 at 09:48 AM
I disabled flare on light that was very close to camera. Fixed.
Your answer
Follow this Question
Related Questions
Raycasting in script suddenly stopped working 1 Answer
cant kill more than one enemy C# 2 Answers
Raycast doesn't collide as it should 1 Answer
How to "Camera.ScreenPointToRay". I get an error in MonoDevelop. 1 Answer
NullReferenceError, Tilemap Array with Transforms and Raycast (C# with Demo) 0 Answers