Bombing run - 30 degrees angle difference


#1

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.


#2

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


#3

How do you measure the angle from the hero?


#4

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


#5

Thanks: it works now!