student activity 5 AI

I am a classroom teacher and all of my students are stuck on activity 5. We create a game attribute called hero x and hero y and then set them "always" to the hero's x and y value. We then push sharply the enemy towards those game attributes and nothing happens. Has anyone else completed student activity 5?

I do not know what the student activities are, but I have an idea on what the problem might be.

I believe the push x, y direction is talking x, y coordinates of the actor and not the screen. The 0, 0 coordinate is in the top left corner of the screen, but in relation to itself, 0, 0 is the top left corner of the actor. Your hero would then be placed at 50, 300 (for example). That means hero x = 50 and hero y = 300. Pushing the enemy, towards 50, 300 in relation to itself would be pushing it almost straight downward. To push towards the hero, you would want the x direction to be "hero x - x of self" and y direction to be "hero y - y of self".

Given the hero is at 50, 300 example. Let's say the enemy is at 400, 300. Subtracting the enemy's coordinates would then give a direction of -350, 0. In relation to itself, that means straight left.

Exactly, I fell in the same trap this morning ! It could be the opportunity to show that the problem is easily written in terms of vectors !If you want to go at (HeroX,HeroY) from (x,y) you have to make the difference ! the push is (HeroX,HeroY) - (x,y)