Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help: Levels in Glacier

No I was actually wrong, I was looking at the wrong line.

You were correct, the vector variable here should be goal.

Okay @Dragonlouis did you do it

1 Like

Yes, did you complete the level?

I think he did, were good

goalPoint = Vector(78, 34)

while True:
    # This creates a vector that will move you 10 meters toward the goalPoint
    # First, create a vector from your hero to the goal point.
    goal = Vector.subtract(goalPoint, hero.pos)
    # Then, normalize it into a 1m distance vector
    goal = Vector.normalize(goal)
    # Finally, multiply the 1m vector by 10, to get a 10m long vector.
    goal = Vector.multiply(goal, 10)
    
    # To avoid the yaks, if you get within 10 meters of a yak, you should vector away from it.
    yak = hero.findNearest(hero.findEnemies())
    distance = hero.distanceTo(yak)
    if distance < 10:
        # First, make a Vector from the yak to you
        vector = Vector.subtract(yak.pos, hero.pos)
        # Now use Vector.normalize and Vector.multiply to make it 10m long
        vector = Vector.normalize(vector)
        # Once you have the 10m vector away from the yak, use Vector.add to add it to your goal vector!
        vector = Vector.multiply(goal, 10)
        goal = Vector.add(vector, goal)

    # Finally, determine where to move by adding your goal vector to your current position.
    moveToPos = Vector.add(hero.pos, goal)
    hero.move(moveToPos)

Um, really sorry but uh I don’t notice the yaks.

Did it work @Dragonlouis

No, I just run into a yak.

show me a screen shot please using command shift 5

I use a windows desktop.

Or use control shift 3

it’s ctrl + shft + s but it doesn’t work in the codecombat.com/play area.

but I’ll just say that I basically used move to move to the goalPoint.

did it work that is a yes or no question :frowning_face:

The goal here, should be vector. You should be multiplying vector and 10.

he’s right and that is all you need

I’m going towards the yak now. I tried changing to subtract but even then it doesn’t work. HELP!

goalPoint = Vector(78, 34)

while True:
    # This creates a vector that will move you 10 meters toward the goalPoint
    # First, create a vector from your hero to the goal point.
    goal = Vector.subtract(goalPoint, hero.pos)
    # Then, normalize it into a 1m distance vector
    goal = Vector.normalize(goal)
    # Finally, multiply the 1m vector by 10, to get a 10m long vector.
    goal = Vector.multiply(goal, 10)
    
    # To avoid the yaks, if you get within 10 meters of a yak, you should vector away from it.
    yak = hero.findNearest(hero.findEnemies())
    distance = hero.distanceTo(yak)
    if distance < 10:
        # First, make a Vector from the yak to you
        vector = Vector.subtract(yak.pos, hero.pos)
        # Now use Vector.normalize and Vector.multiply to make it 10m long
        vector = Vector.normalize(vector)
        # Once you have the 10m vector away from the yak, use Vector.add to add it to your goal vector!
        vector = Vector.multiply(vector, 10)
        goal = Vector.add(vector, goal)

    # Finally, determine where to move by adding your goal vector to your current position.
    moveToPos = Vector.add(hero.pos, vector)
    hero.move(moveToPos)

try to say goal instead of vector here

didn’t work. I found out that I wasn’t going towards the yak, I was going in that direction.

Okay I don’t know what to tell you now I gave you all I know