P
Pablo Reese
Guest
I have a top down shooter, where there is an enemy that will calculate where the player is going to be by the time his bullet reaches the player. He needs to aim in front of where the player is so that his bullets are harder to dodge. I want to use the player's move speed and direction, along with the enemy's position and bullet speed, to calculate where to aim.
The player moves at a speed of 3, and the enemy bullet moves at a speed of 5. Here is the code used in the player's movement:
I need to know what calculations should be made to find the angle that the enemy aims at any given time. Thanks! I appreciate it! Let me know if any more info is needed.
The player moves at a speed of 3, and the enemy bullet moves at a speed of 5. Here is the code used in the player's movement:
Code:
//Movement
var xDirection, yDirection
yDirection = keyDown - keyUp;
xDirection = keyRight - keyLeft;
y += yDirection * moveSpeed;
x += xDirection * moveSpeed;