Physics.RaycastAll.Length incorrect?

Maybe i m missing somthing but Physics.RaycastAll seems to change the range somehow on its own.

	for(var i : int = 0; i < 128; i++){
		for(var k : int = 0; k < 128; k++){
			if(container.d2[i,k]==houseint){
				hits = Physics.RaycastAll(Vector3(i,k,0),Vector3(i,k,128),128); // tried also Mathf.Infinity for the range
				print(hits.Length);
				for(var j : int  = 0; j< hits.Length; j++){ 
					container.d4_bool[i,k,parseInt(hits[j].point.z+0.5),0] = true;
					print(i+"x "+k+"y "+parseInt(hits[j].point.z+0.5)+"z ");
					//print(hits[j+1].point); got the expected out of range error
				}
			}
				
		}
	}

And here the Different resaults:

somehow it got right:

and the wrong one:

any idea why this is happening?

ok let me try to explain the problem in a other way:

I want to scan witch the Physics.RaycastAll methode, in the end i need a array in wich is each hit sorted by the x,y,z cordinates . but for some reasons the racast changes the range. I m thinking about doing that with a trigger but i m not sure if thats a fast way to do it and raycast should in my understanding do the job.

if Physics.RaycastAl isl buged maybe you know a alternitive.
(sorry for the dopple post)

This line confuses me about your code:

hits = Physics.RaycastAll(Vector3(i,k,0),Vector3(i,k,128),128);

Raycast all is a “Ray” cast, a Ray, is defined as an origin and a direction. It appears that you are trying to think of it as a Linecast.

var origin = Vector3(i,k,0);
var dest = Vector3(i,k,128);
var direction = (dest - origin).normalized;
hits = Physics.RaycastAll(origin,direction);

oh thats it! I must been blind :slight_smile:

i m using now:

hits = Physics.RaycastAll(Vector3(i,k,0),Vector3(0,0,1),128);

thx for the help!