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

yes please everyone wants this

2 Likes