Bombing run - 30 degrees angle difference

I was able to solve bombing run, but I needed to add an extra 30 degrees to my atan2.
I compared with other codes posted in the forums because I cannot find the reason behind this additional 30 degrees, their codes where quite similar to mine but without the 30 degrees. Any suggestion?

while True:
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        # Find the vector of attack
        # Use trigonometry to find the the angle in Radians!
        # The answer must be in Degrees!
        # To convert Radians to Degrees multiply by (180 / Math.PI)
        angle=30+(Math.atan2(enemy.pos.y,enemy.pos.x))*(180/Math.PI)
        # Say the angle!
        hero.say(angle)
        hero.wait(4)

If I should not post working code, just let me know and I will delete it.

1 Like

I think it’s because you are measure the angle from (0, 0) point instead from the hero.

2 Likes

How do you measure the angle from the hero?

1 Like

You can use Vectors for this if you have Programmaticon V. Or instead enemy.pos.x use enemy.pos.x - hero.pos.x

1 Like

Thanks: it works now!

1 Like