I'm making a platformer game where your character is defenseless, and has allies follow him, which attack enemies when clicked. To make the allies (which are individual objects) follow the character, I use the code (in the step event)
mp_potential_step(character.x,character.y,5,0);
And I use the same for the enemies, except a bit differently:
if (distance_to_object(enemy)< 100)
if (instance_exists(enemy))
mp_potential_step (enemy.x,enemy.y,1,0);
(I change the speed depending on the ally's ability. This one resembles a bomb, and so it follows the character quickly, but follows the enemy slowly. The enemy is just an object that paces imbetween two other objects, which send the enemy in the opposite direction on collision. This works well, but the problem is, because of the speed, (I'm guessing) the allies always go toward the character, even if its farther away. What I hope for it to do is go for whichever object is closer. (which enemy, or character) This way, since you have to click the ally to activate its ability, it will hopefully make it easier to aim, attack, and target. Any ideas?