Make friendly characters follow player (like in top-down RPGs)

How can I make other characters follow player? I’m making a top-down game and I want some other characters to follow player, just like in top-down RPGs (Earthbound, FF, etc.), with proper animation (walking and idling). I kinda did it with pathfinding behaviour on friendly character and “move to player X and Y” action under “Always” condition, but it works pretty ugly.
How can I do it properly?

Hi, there is an extension called “Animate Shadow Clones” which adds to your primary object (e.g. your player) a number of clones (you can set the number and other parameters) of another object. These clones will follow the primary object in the same way as the primary object moves.

This is quite nice but unfortunately not the solution for your problem as only one clone-object can be added to the primary object. So instead of having a number of different characters follow the player, you would have only one or several versions of one and the same character. Adding the extension twice or more with other clone sprites to the primary object seems not to work (you could try that nevertheless).

So what I would suggest is to take a look at the extension in the editor and use the events that are responsible for tracking the movement of the primary sprite and let the clone move in the same way. The extension is quite complex because the movement of the primary object is stored in variables which are used for setting the movement of the following objects.

2 Likes

Wow, that’s awesome, works great, almost. The problem is I want to stop clone behind the character, but it goes to the player’s position and merges with player character. Is there any way to stop clone at desired distance from player?

I tried a few things by altering some values in the extension (e.g. changing the point where the clone is created or adding some distance to the creation point) but it had no effect. Probably I miss something on how to apply the changes in the extension to the project.

Generally, you want the clone object only if you are moving so you could use that as a condition to create the clone. If the player is not moving you can delete the clone and have the sprite of the following character (which is the clone) created next to your player.

Using the “move towards object” action will be smoother than pathfinding. You can use “separate objects” action to prevent the npc from standing inside the player object.

There is a problem if a wall gets between them… you could use raycast to detect walls between them and if so, switch to using pathfinding again until there is no wall between them… then switch back to "move towards object’ method

Another totally different way is to have the NPC duplicate the player’s movement, but with a delay. This results in the NPCs following behind like a snake tail, following the path the player took.

You could add an object array variable and 4 direction movement behavoir to NPC (turn off default controls). When the player moves, add the direction pressed (“left” “right”, etc) to the array. After the array grows to a certain size you can choose (determines how closely NPC will follow) you can remove the first element of the array and simulate movement for the NPC in that direction.

Shadow clones extension does exactly this, and I found it as the easiest way to achieve what I want

Empty frames between player and NPC-clone and condition that allows NPC-clone to move only when player moves fast pretty much does the job, the only quirk is when player moves slowly, extension does not capture its movement, so when player gains speed clone gets teleported. Other than that, it’s almost what I wanted.

hello was wondering if u found the solution to this :slight_smile: