Help on Bombing Run [SOLVED]

I don’t understand some of the concepts. Here is my code:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # Find the vector of attack
        vector = Vector.add(enemy.pos, hero.pos)
        # Use trigonometry to find the the angle in Radians!
        radians = Math.atan2(hero.pos, vector)
        degrees = radians * (180 / Math.PI)
        hero.say(degrees)

There are no errors, the hero doesn’t even say a number. I think this part of the code:

        # Find the vector of attack
        vector = Vector.add(enemy.pos, hero.pos)
        # Use trigonometry to find the the angle in Radians!
        radians = Math.atan2(hero.pos, vector)

is incorrect. Can someone please help? And maybe even explain what the answer means?

1 Like

which area are you in for that level

1 Like

I don’t know what you mean.

1 Like

It’s in the glacier. (don’t want to confuse anyone :wink:.
:lion:

1 Like

You have located the incorrect code.
vectors
A is the vector of your hero.
R is the vector of your enemy
B is the griffins’ attack vector

2 Likes

Can you please explain the diagram? I really want to understand this.

@Deadpool198
Actually, it’s in the glacier.

1 Like

Actually, I figured it out. Thanks to everyone for replying.

1 Like

Ha ha, I didn’t realize.
:lion:

1 Like

Maybe This Can Help??

while True:
enemy = hero.findNearestEnemy()
if enemy and hero.distanceTo(enemy) < 70:
O = Math.abs(enemy.pos.y - hero.pos.y)
A = Math.abs(enemy.pos.x - hero.pos.x)
angle = Math.atan2(O, A)
angle = angle * 180 / Math.PI
if enemy.pos.x < hero.pos.x:
angle = 180 - angle
hero.say(angle)

Please … DON’T revive dead topics, it isn’t something to mess up with, you can get banned because of this, also, this is already solved

1 Like