Download

Spline path - go forward, never back

Hi!
I’m making a car to follow a spline. Simple…find closest location to car’s forward vector*500.

The problem is…if the car doesn’t make it and makes a U-turn, it often starts following the spline in a wrong direction. I’d like to limit the closest locations to only following locations, not previous.
I came up with a solution but there’s not a function it requires and I have no idea how to make it differently.

Picture:
Red curve - the “passed” part of the spline
Green curve - the part of spline which is still to be riden
F - the closest location at the spline
R - historically the most advanced closest location at the spline
If (F > R) then R = F

Currently the car follows the F (which leads to riding the spline in the wrong direction)
And I want it to make R which only advances to let the car follow it.

I’ll be grateful for a solution

PS: I hope my explanation is understandable, my abilities to explain suck today.

Reducing the * 500 may help try 100
Paul G

Thank you!
There’s something about it, sounds like a good reduction for this issue.
Unfortunately, as soon as the car already gets on the track in the wrong direction, this solution doesn’t work anymore.

I don’t use it but the method I have seen used a lot is to have an invisible actor eg sphere travel along the spline and the “car” follows the sphere

Thank you! This gave me an idea which might work!

Currently, the car only gets the current nearest location (vector) of the forward vector at the spline, which results in the issue.

However, I can replace the current vector with an actor/car’s component (I’ll call it “actor”). As long as the car’s forward vector’s distance to the actor is short enough, the actor would move along the spline, else it would wait for the car to catch up.
(now I realised there would be no need to actually use the actor, a simple vector should be enough)

I believe you just gave me the poke I needed to resolve this issue! Thank you for that, frustration from this inconvenience prevented me from continuing on the project. Thank you once again!