Sending raycasts in multiple directions

I currently have a track with nodes on that a train follows and I’m currently using raycasts to detect the next ongoing node, however on tighter corners it fails to detect and stop. Is their a way to send out multiple rays to detect the node?

diagram
(tried my best on the diagram sorry it isn’t the best)

2 Likes

You probably want to just somehow label these nodes manually as you’re building the track, then you can just look up the next node.

You’d have to get pretty dense with your raycasts to make this work well, and even still there’d still be edge cases.

You could also probably just loop through all the nodes and find the next closest one by doing a bit of math.

If you want to try raycasts anyways, you can use something like this:

3 Likes

Thanks for the suggestions, I’ve decided to use magnitude to detect the next sensor, then point the raycast in that direction. Seems to have improved the issue a lot.

2 Likes