# How can I detect a collision between any 2 points of a path/spline?

Hey all. I’m trying to put together a spline system for my project which is a 2.5D platformer where you move on a path in 3D space kinda like Kirby 64 or Klonoa. Right now it only works when the player starts out by touching a spline point (1 of many spheres in a nested game object that manages the spline). Part of the game involves the player being able to potentially leap off the spline path they are on and then be put onto another spline. What I’m trying to figure out though is how the player object could see another path from a distance and then through a raycast, actually know that it’s hitting the line between any 2 points of the spline and then can move to the right position of that spline. Unity doesn’t have colliders that I can create for lines between all the spheres/points of the spline. I think colliders even if they were generated might get messy too. I was also thinking about having a loop that iterates through all points of the spline and detects if a player has joined up between each of the points but that too could be costly with more splines in the scene. Does anyone have any ideas of how this could be implemented and simplified/not overengineered?

The pic shows that I have 2 splines. 1 is on the main line and then the other if the player is near should be picked up by some raycast from the player. the player should be able to hit/detect a line between the spheres on that outer platform/rectangle and then be able to join up.

Yes, you won’t be able to do it with raycasts unless you create a collider for the spline segments.

One simple approach seems like a problem where you need to find where two lines intersect. From the picture it looks like that spline segments are straight lines. If so, finding the intersection is a simple equation.

If you are working in 2D ( 2.5 D is just due to your camera angle?) create a line segment in x and y on the same plane that the splines exist on, that originates from the player outward in the direction they are looking. The other end point of this line segment can be set at some distance from the player.

From there, you may need to iterate over each line segment in the spline. There will be some nuances to contend with, like if the player line intersects more than one line segment in the spline.