Better Raycasting Distance

image
image
So raycasting does this thing where is returns the distance from the player to the object it hits, instead of the distance “traveled” by the raycast. It is possible to work around this (Tinkersmith made an example), but it’s very laggy and not practical for actual games. I was hoping that it’d be possible to make it return the actual distance? Or at least an option to choose between the objects distance and the traveled distance. I think it would make 3d games in flowlab look a lot better!

6 Likes

You could use distance formula.

1 Like

Sorry I should’ve explained it better. The raycast is returning the distance to the center of the object, I want it to return the distance to the point that it hit. I couldn’t use the distance formula because the coordinates of the spot a raycast hit is unknown

3 Likes

There’s not much else you can do, the best would be to optimize raycasts. You could use a ton of complex triangle constructions and use the Pythagorean theorem to calculate the hypotenuse and angle.

2 Likes

It’s been known for a while

2 Likes