MV NPC move to last position of other NPC

Hi all, I'm looking for some help in that "simple" question. Is it possible to make an NPC move to the last position of an other NPC?

I'm trying to make a giant snake on a map. Therefore I've decided to create the "head" of the snake as one NPC that has a random move route. The body parts and the tail of the snake should follow the head. But if I just tell them to "follow" the bodypart in front of them, the snake will move left/right as one long stick...

So the solution would be, to tell each body part to go to the old/last position of the body part in front of itself.

THX in advance
The best solution would be making a giant sprite with the approriate frames for animation. Moving many separate events like that is probably impossible, unless they perhaps follow a specific route.
Hi all, I'm looking for some help in that "simple" question. Is it possible to make an NPC move to the last position of an other NPC?

I'm trying to make a giant snake on a map. Therefore I've decided to create the "head" of the snake as one NPC that has a random move route. The body parts and the tail of the snake should follow the head. But if I just tell them to "follow" the bodypart in front of them, the snake will move left/right as one long stick...

So the solution would be, to tell each body part to go to the old/last position of the body part in front of itself.

THX in advance
How does going to the last position of the body part in front differ from following it?
The best solution would be making a giant sprite with the approriate frames for animation. Moving many separate events like that is probably impossible, unless they perhaps follow a specific route.
I've already thought about that, but it would be very "clunky" if the sprite change directions. There would be no "flow" in its movement.


How does going to the last position of the body part in front differ from following it?
I try to explain it:
If NPC1 goes down and NPC2 is behind him, he will follow on his last position.
But if NPC1 goes right or left, NPC2 will do it also. Since it is following, it just goes the same directions.
This makes the "snake" looking like a stick moving sideways. | -> |
I've already thought about that, but it would be very "clunky" if the sprite change directions. There would be no "flow" in its movement.
Not really. You can make as many charsets as you need for a smooth animation and just swap event pages on and off as needed.

But overall, there's a reason why huge sprites are usually stantionary, even in old triple A titles.
I believe Yanfly's Move Route Core offers a "Move toward X event" option :LZSskeptic:
Would that work for what you are looking for?
this can only be done easily if the head is NOT on random movement.

if you know where the head goes, you can handle the rest.

and when controlling the head movement you can store where it goes to give the next command.

however this is much more difficult if you don't know the main movement of the head.
You could put the movement into the event commands.

That way you can have the top of the event store the current coordinates of all the other events into variables, then control all of the movement from there.
To be honest, I don't quite see why a random moveroute would even be beneficial. If the snake is long, the random movement combined with the follow command will just end up making the snake get tangled eventually.

What you would need is what @ATT_Turan said. You don't give the events a follow command, you give them the last X and Y position of the event in front of them, so they retrace the exact steps instead of just making sure to use the closest movement in order to be on the next available tile.
I believe Yanfly's Move Route Core offers a "Move toward X event" option :LZSskeptic:
Would that work for what you are looking for?
I've already tried it. Its has the same effect as I described on my other post. The snake moves sideways.

+The reason the head needs random moveroutes is, it should follow and attack the player, if he is nearby. If I create a scripted moveroute for the head, it would act like a stupid snek making its rounds.. not responding on players presence.

Then if the player is not around, it should move throu the map + the map is quiet big
+The reason the head needs random moveroutes is, it should follow and attack the player, if he is nearby.
That's not random 😛 That's moving with a specific logic.

You'd do what I said above (rough pseudo-code):
-Control Variables -> head event X
-Control Variables -> head event Y
-Control Variables -> First body piece X
...etc. however long your snake is
then
Move Route -> head -> Move toward Player
Move Route -> First body piece -> move toward stored head X, Y
Move Route -> Second body piece -> move toward stored first body piece X, Y
etc.
Wait: however many frames you want

You'll need to use Yanfly's Move Route Core or some similar plugin for "move to coordinates" commands.
That's not random 😛 That's moving with a specific logic.

You'd do what I said above (rough pseudo-code):
-Control Variables -> head event X
-Control Variables -> head event Y
-Control Variables -> First body piece X
...etc. however long your snake is
then
Move Route -> head -> Move toward Player
Move Route -> First body piece -> move toward stored head X, Y
Move Route -> Second body piece -> move toward stored first body piece X, Y
etc.
Wait: however many frames you want

You'll need to use Yanfly's Move Route Core or some similar plugin for "move to coordinates" commands.
tried it out, unfortunaly there is no "move to variable x,y" command in this addon :/
is there a script that can do that? like this.moveToVariable(x)
Okay got a breakthrough here.
As ATT_Turan said, I controlled all variables from head to the last body part with X & Y coordinates as a parallel event.

The head has random routes + follow player as he is nearby.
the other body parts got a condition branch with:

If head X > Bodypart2 X -> then -> move (this event) right.
I wrote this with all 4 directions for all bodyparts. Every body part if focused on the one in front of it.

Thx for helping so far guys!
It looks like you got it figured out! Otherwise, it would be a simple bit of work for someone to help you mod the Yanfly plugin so that Move: X, Y could accept JavaScript eval for the two coordinates.
if an snake is an event, there is an plugin to use it for followers.
Burning Orca (BO) has a FollowControl (for events and battles) which
require PluginBase of his found here.

you can make a snake version of it if done correctly, as I didn't test
or use that kind, but it should do what you want.

there is also another, but that is more actor based for player to get
infinite followers for players, but I dont know who made that one.

Original thread: https://forums.rpgmakerweb.com/threads/npc-move-to-last-position-of-other-npc.154059/