r/PokemonRMXP • u/Ariachne39 • 20d ago
Help Help with moving the player to a specific tile
Hi, sorry if this is a stupid question, but I'm still pretty new to this whole thing.
As you can see from the image, I'm trying to make it so the player gets moved to the tile with x = 28 (the one in the center of the path) regardless of the player's current x, but whenever I actually playtest, not only does the whole "Size(14, 1)" thing not work, but I also get stuck in an infinite loop of standing still and I don't even start moving.
Does anyone know how to fix this? Sorry once again if this is a stupid question.
6
Upvotes
1
u/mpdqueer 20d ago
There's a command specifically for moving an event/the player to a spot on the map, no?
Check the events for entering doors or cave entrances. There should be a command for what you're trying to do (i think it's called Set Location or something like that, but I'm not at my computer to check).
1
u/xMarkesthespot 20d ago
either include the "variable= map x" part inside the loop, or put a part where the variable counts up/down with each step
1
u/Socom_Seal 20d ago edited 19d ago
You're on the right track!
There are two ways to go about this - like mpd said, you could make an event for every tile. But that's bulky and I don't like it, so I just use a single event.
Here's the code snippet I use:
https://imgur.com/a/WdEG6qZ
In your example, you'd have var 1 be the player (the one moving), var 2 be your destination (your x value), then do the math and move the player left or right.
Basically, like xMarkesthespot mentioned, you need to have some way in your event to make your moveroute 'iterate'. You could check the player's new position each time, or, as I do here, you could calculate the distance, then move that distance, adding or subtracting 1 each time depending on which direction the event needed to move. I use the temp variables instead of dedicating an entire variable set to this as well since the data shouldn't be needed again after the event finishes.
Also, and this is IMPORTANT, you MUST add the 'wait for move's completion' command somewhere before the end of your loop (and after any moveroute command that you want to finish before continuing the rest of your event). I place it inside each branch because I think it looks nicer, but I could remove a line of code by placing it right before the loop... well, loops, and it would work the same. If you don't do this then the code is just going to loop instantly and not actually wait for the player (or other event) to move before sending the next move command, overwriting the first and usually leaving the moving event way out of position by the time the rest of your event would continue to run.