Advanced traffic light

Hey,

When working on my traffic lights I came up with a problem I wasn’t thinking about earlier. So my problem is that I made a light script which for the lights was very easy. Then I created a trigger on the ground and when the car comes it will brake. So my problem is that I want the car to stop right under the traffic light not a couple of feet earlier or later.

I get smith like this

[car] —>-------->----->- |traffic light

so what I want is that it stops right in front

[car] - |traffic light

and not sometimes

[car]----|traffic light

or so

[car]–|traffic light

so the - is supposed to represent the distance between the car object ([car]) and the traffic light (|traffic light)

and I always want the car to stop at the same distance

When the car gets the OnTriggerEnter() message it can check the position of the other collider and make it its destination point to which it would gently approach with, say, Vector3.Lerp.

Best regards,
Peter.

well the problem is that I am steering the ai cars through throttle input between 1 and -1 and a steering of 1 and -1 so that allowed me to have realistic physics and so the vector3.lerp is kind of not really matching my needs

i thought of maybe having some kind of forcefield that would increase the friction at the stopping point to a maximum. But that would be kind of expensive on performance