Hi! I’m building a game in which you need to shoot at different objectives that are moving really fast and I wanted to add a shooting predictor. I implemented a function that returns the predicted impact point and I’m using it both for the player (a prediction point is shown on the GUI) and for the AI, as they also need to aim there. This is my implementation:
It kinda works, but unfortunately, due to the accelerations of the different objectives, AI can’t hit most of the times. I want my AI to be deadly and to be able to hit the objectives as good as any player, but apparently, with that predictor is not enough. Any ideas?
Taking the velocity of the shot you can calculate the time it will take to reach the targets current position. Time = (Distance between You and Target) / Bullet Speed
Use the result multiplied by the Speed of the target you can get an intercept distance. Intercept Distance = Time * Target Speed
Targets forward vector * Intercept distance will give you the lead padding. Prediction Location = Target Location + Padding
This works nicely! But apparently my problem was my collision avoidance system. AI was trying to aim at the objectives but as soon as it was alligned to shoot, it detected the objective as an obstacle and turned away. Solved it by using 2 different avidance systems: one for the envirnment with a lot more reach, and another one for the objectives with less reach to let the AI shoot.