Well then, as far as I know the only other problem could be that the turret can’t find the closest enemy. Give me a day to think I’m tired right now lol
This method ^ ^ ^ ^ optionally takes a second argument that is your UP vector for the purposes of looking. This defaults to Vector3.up. If that is not UP in your setup, you will get incorrect results.
Alternatively, here is my turret aiming code… it has traverse but also includes elevation, like a battleship gun, but you could just use it for the traverse and disregard the elevation portions.
Thank you so much for help. But as Player Car is moving and Target Car is also moving, Maybe that’s why turret is always targeting little behind of target(No bullet hitting target). This is my code now:
The simplest target predictor estimates time (based on distance and bullet flight) to impact, then extrapolates the target’s relative velocity and uses that new point as its aimpoint.
This works best if the target is moving 90 degrees to your bullet path. Any other angle will have error.
Error can be accommodated by:
final steer (cheating) with the bullet
having the target / bullet hit radius larger so it still hits
A more advanced predictor observes each shot and adjusts it.
ALL of these predictors presume relative target velocity remains constant.
Tower defense predictors usually cheat by choosing in advance where the bullet will connect, then tweening the bullet there as a function of the target’s distance from where it was when the bullet fired to where it was at intended impact, and faking it.