# Ray Casts outputs distance traveled

If I have an object 320 pixel away a ray cast will output 320, which is correct, but if I hit the object at a 2 degree angle it will still output 320, even thought the distance is now greater. (Can be fixed with sine)

3 Likes

It does do that, the hit outputs a number (which is the distance) I really donâ€™t know what this means either.

2 Likes

If a ray casts is hit after 50 pixel, it will not output 50

1 Like

What does that mean, though? after 50 pixel? pixels arenâ€™t a unit of time and raycasts are a frame long.

2 Likes

If I have an object 320 pixels away (A unit of distance, not time) when it hits that object (In a single frame) itâ€™s output will not be 320 (That is the distance the ray cast traveled, starting from where it was first cast from)

1 Like

What will itâ€™s output be then?

2 Likes

wait this is wrong, I thought there was something about the ray cast that was annoying. I donâ€™t remember what it was

1 Like

Oh ok I remeber now. If I have a ray cast hit a object straight on it will output 320 if it is 320 pixels away. But, if I hit it at a 2 degree angle it will still output 320 even though the distance traveled is greater than hitting it at a 0 degree angle.

2 Likes

Oh, I see, you were saying that it doesnâ€™t output the raycastâ€™s length, it outputs the players distance to the object the raycast hit.
you could fix this with some math, but it would require sine.

2 Likes

Raycasts output the distance from the casting objectâ€™s center to the target objectâ€™s center, so a ray hitting anywhere on an object will output the same distanceâ€¦lots of people have requested an option for raycast to output actual distance to the rayâ€™s collision point on the object, though as far as I know Grazer hasnâ€™t said whether it will be added or not

4 Likes