Hello, Im making a simple racing game, and want to detect when the player is going the worng way on a race track. I know how I would do it if the track was a straight line, but I cannot come up with a solution for a circular or curvy track. How would you solve this?
If you already know the direction of the track (we don’t know how you made it), dot product
said direction against the racer’s forward vector
.
If you do not know the direction, add a spline to the track. Query closest location from the racer and then dot product foward vectors.
Dot goes from -1 <=> 1. Anything above 0 is the right direction. It describes how aligned two vectors are.
Should work OK until someone faces the wrong direction but drives in reverse, ofc. Additional queries would be needed here, based on velocity.
Perhaps the whole thing should be based around velocity instead. If someone is airborne, cartwheeling and doing flips across the finish line, we probably should not red-flash them with WRONG WAY. It’s just their style…
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.