It's all fine having a start point and an end point, but adding a new point in the middle doesn't seem to be possible without having more information about what the player is trying to do.
I can add new points to the end easy enough.
But adding a new point causes any object moving along the path to jump slightly, since it's position is relative to the path length.
You can add points before an existing point, but I don't think I can calculate what that point is based on new point location alone?
I'd have to do some sort of check for nearest point?
Hmm
Here I'm running through all the points in the path, if it finds a point closer to the mouse click it will insert the new point before it.
This works, but you can't place a point before the first point, and placing one too close to the last point reorders the whole path
I think I might have to use a conveyor belt method instead, where you place objects or assign grid values as track and direction and touching them pushes you in that direction?
You'd continue to move in that direction until you hit a stop block, or a different direction block.
To save objects I'd have to check adjacent sides for existing ones that would move you in the same direction. Although Grid method would avoid that I think.
2 comments