Since I'm making an RPG and I'm trying to make the NPCs travel between layouts, I have thought of a pseudo that might work for them to be able to do that. I have not tried this but I'm gonna post steps. Try to correct me if it wont work or something or give some suggestions etc.
Assuming I have all the things I need (objects etc..):
1. Make a set of global variables for each NPC (or just a global array).
2. Make the NPC objects global.
3. When an NPC enters collides/overlaps/i dunno a "warp" object, depending on which warp object, it will it put some values in that NPC's global variables like its warp destination(layout name and position). A variable that will contain its destination will also be inputted by a value.
Ex. Lets say NPC1's global variable "place" has a value of "village1" and its global variable "posX and posY" have 10,250 as its values respectively. When it collides with a warp object that suppose to enter village2, the GV "place" which has a value of "village1" will be replaced with "village2" and lets say the posX and posY GV is replaced by some a certain value. After that, an event will take place wherein NPC1 will be teleported to the layout and position base on its GV "place" and "posX" and posY". After that, NPC1 in village1 is destroyed.
Ofcourse, besides those 3 GV (global variable), there will be other variables to be included (I guess
So that's my uhhh algorithm for this. Any help? Recommendation?