- Home /
How to detect player car overtake of other cars
I am working on top down racing 2d game. I am working with Unity engine from long time so I am very well aware with most of concepts.
Basically I want to detect overtake of player car with other cars, I know a way using ray casting but as per my assumption it become costly operation and reduce game performance.
So I want some suggestion from you friends. I hope I found some intelligent way from you guys.
Is it possible to use the racing line to get the distance between each car and the finish line? Wouldn't that be the easiest way actually?
Answer by calmcarrots · Aug 17, 2014 at 06:44 AM
I currently do about 300 raycasts per second in my game and I run the game at 300 fps. I have a lot of other things running in the background like AI, physics, particles, general game logic, bullets, etc. Dont worry, a few raycasts dont really hurt performance. They take very little
Your answer
![](https://koobas.hobune.stream/wayback/20220613160801im_/https://answers.unity.com/themes/thub/images/avi.jpg)