How can I calculate where the player will be considering his movement speed and direction as well as the bullet speed and shoot accordingly in the calculated direction?
I haven’t done this yet, but my idea is for the AI to get the velocity (speed and direction) of where the player is going, then fire ahead of the player on the XY axis.
You can also do Z if you want to shoot the player out of the air.
Thanks for the answers!
I don’t think the solution in the video is correct. He is dividing the distance between projectile and player by the speed of the projectile to get the time it takes to reach the player. Then he multiplies it with the velocity of the player and adds the result to the current player position.
But this calculation is just an approximation and can be very inaccurate. As shown in the thumbnail of the video, the distance to the shooting position might be shorter than the distance to the current position of the player (resulting in shorter time and shorter travel distance for the player).
As a solution I am looping these calculations until a certain threshold is reached, which results in very high accuracy. But I feel like there should be a simpler solution. Any ideas?