Dance Off Help Needed

My code seems correct and I even followed the video tutorial but my hero just stands there.
@Serg @Bryukh @nick

while(true) {
    var friend = hero.findNearest(hero.findFriends());
    var offsetX = friend.pos.x - hero.pos.x;
    var offsetY = friend.pos.y - hero.pos.y;

    hero.move({x: friend.pos.x - offsetX, y: friend.pos.y - offsetY});
}
1 Like

Maybe use "x" and "y" instead of just x and y?

1 Like

I don’t know, hero just stands there. All of the other people who solved this had identical code to me so I don’t get why mines wouldn’t work.

1 Like

Tried it, didn’t work

1 Like

Also do you have boots with move ability?

2 Likes

I have the Fine Boots and Boots of Leaping. Neither will work

1 Like

Seems like a bug. Maybe contact @serg or @Bryukh or somebody.

1 Like

Fine boots do not have move.
Updated: Oops, they do. I was thinking of the softened leather boots :joy:

1 Like

I sent an invite to them

1 Like

Great! :+1:

(Post must be at least 20 characters.)

1 Like

Your code has one mistake (two technically). Try to “debug” it in your mind. What is happening in each cycle? You find offsets and move your hero to the friend’s position plus offset, but what the new position is? Yes, it’s your hero position. I suppose you can find the answer already, however, if it’s not enough, say me and I will add a hint :wink:

4 Likes

I’m still confused because in the while loop, every new cycle, offset will be redefined as the friends NEW pos.x - hero.pos.x

2 Likes

Yes, so you don’t need to redefine it. You need the initial offset (at the 1st frame) then use only it.

3 Likes

Thank You, that solves it. I put the friends and offsets outside of the while loop and it worked.

2 Likes