Legacy GM Make object follow player

B

bleuthoot

Guest
Hello,

Before you read:

  • the player = obj_plr1, you can control this player with your keyboard
  • the partner = obj_plr2, this player is supposed to follow obj_plr1
I'm currently testing something that lets obj_plr2 follow obj_plr1. I currently have this (It's not much).

I wanted it to look like this

You can currently move the player and nothing else.

I have already tried some things:

  • Let the partner go to the player using move_towards_object(obj_plr1), this worked but not really in the way I wanted
  • Use the exact position with a 32 pixel difference (This didn't work at all). In the step event of obj_plr2:
if (keyboard_pressed(vk_up)) x = obj_plr1.x - 32;
if (keyboard_pressed(vk_down)) x = obj_plr1.x + 32;
if (keyboard_pressed(vk_left)) y = obj_plr1.y - 32;
if (keyboard_pressed(vk_right)) y = obj_plr1.y + 32;


How do I do this?
 

sp202

Member
If you want something exactly like that Mario gif, easiest thing to do is to set the second player's x and y to the first player's previous x and y.
 
Top