Tag Info

New answers tagged

0

Augment your finish line point with a direction vector representing the "forward" direction. Then, instead of: if (Vector2.Distance (finishline.position, car.position) != 0) [...] Do: if (Vector2.Dot(car.position - finishline.position, finishline.direction) > 0) [...] Note, if the direction happens to be aligned to a cartesian axis, say +X, the ...


0

This wouldn't answer the question of measuring the distance but for the scenario that you described, I find that placing a collider as trigger on the finish line and checking OnTriggerEnter in your car would be a better solution rather than calculating the distance. For distance check, Dexyne is totally correct but you could also check using the ...


-1

Update – My bad, as @DMGregory says the value of a distance cannot be negative (and it makes sense). As @Kimserey and I says, you can use a trigger. Probably better in this case and easier to use. when the distance between the car and the finish line hits or goes under 0 I think the problem is your if statement. Your test should be: if ...



Top 50 recent answers are included