Dance Off Help Needed


#1

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});
}

#2

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


#3

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.


#4

Tried it, didn’t work


#5

Also do you have boots with move ability?


#6

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


#7

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


#8

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


#9

I sent an invite to them


#10

Great! :+1:

(Post must be at least 20 characters.)


#11

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:


#12

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


#13

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


#14

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