I made this test code! I think it does what you want:
There’s basically two components to it:
-
Creating a custom projectile that shoots in the direction of the hero. The easier way to it is to set the vx to be the distance of the hero from the enemy in the x direction, and vy to be the distance in the y direction. The problem is that the closer the hero is to the enemy, the slower the projectiles will be. To fix this, I added the “normalizing ratio” variable, so that no matter where the hero is, the projectile will have the same speed
-
Checking to see if the hero is in range. This is done by the distance formula
Lemme know if you have questions! The math is kind a pain, but I can explain better if you’d like to know! otherwise feel free to use this code