Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to handle this raycasting problem?

Asked by 5 years ago

So on a 2D game (port) I've been working on, there's been a bit of a big issue. I've needed a function that gets the distance from a specific point to a floor or wall. I decided to go with raycasting because I thought it'd be the easiest and fastest. I've been trying for weeks, to no avail.

The issue has been the way it specifically has to work. So basically, if the point given is inside of a part, it has to try and get the distance all the way up to the surface of the part, and if it isn't it just finds the surface below. This would be easy, but there's 2 factors that are in play here.

1: Complex geometry is made up of multiple parts, meaning the raycast will have to know how to get out of it. 2: Which surface Roblox gets when inside a part, and casting to another part is seemingly random (it can either be the bottom of the next part, or the top of the part it's inside).

If the point is inside a part it'll either hit the bottom of another part, or the top of itself... or it'll either hit the bottom of the part it's inside, or the floor of the next part. I need help with this.

Are there other libraries or just a solution I haven't thought of to solve this?

Answer this question