Can I make a cart follow the rail?

Do anyone know if there is a good way to make a cart follow a rail? I've been googling but I can't find much about it. I want to push it along the rails one or two blocks at the time, I can push the cart around fine, but I can't find a way to force it to stay on the rails.

I also wan to be able to push it from behind and have it go around corners without me having to stand directly behind it. Is this possible? Maybe somebody know of a tutorial dealing with something like this?
There are several ways - but none easy.


Basically you need to determine the path or the position to preselect the possible moves for the select move route.


If you can give more details about what you want and how large/complex the railpath will become, we can give more specific advice.
It's not gonna be much bigger than this, not very complicated.

railway.png

Here I've tried to mar some of the problem areas. I can make the switch work though as long as I find out how to make it stick to the rail.

railwayproblems.png 

I suppose my biggest problem is that I can push the cart off the rails and the cart gets stuck in the corners. Not sure how to explain it better.

It's okay if the solution is complicated, I don't know how to write ruby scrips yet, but I can use them if someone else have written them already. I'd prefer a non scripting solution, but if it's the only way that's okay.
In that case I suggest you use Yanfly's restrict region script and make the borders of the rail with the region number set for "no movement by events". That way the regular passability still counts for the player.


(I don't have the link ready, search that script on the master script list)


And in the move route of the cart you set the move for "away from player" instead of a specific direction. That should allow the event to move to the side if the direct away is blocked (I haven't tested it however)
The script helped, at least it stays on the path now so thanks for that. The other thing did not work though, I don't have the move path set to a specific direction, just "away from player". If I have the "Skip If Cannot Move" on then it does nothing when it hits the wall, if I turn that off it actually freezes the game as soon as it hits a wall.
too bad - I hoped it would be able to slide.

Can you post a screenshot of the event? that might help solve the remaining issues
The event is becoming a bit more complicated than I wanted it now. I figured out a way to work around the getting stuck thing, but it requires 2 two switches and two parallel events for each turn. Maybe just one switch if I use a variable. Anyway, this is what I have now, this gets past the first two collisions one directions.

EventScreen.png 

Might not be so easy to see from the screen, but basically when the cart hits a collision point an event running parallel turns on a switch that tells it to move a few steps till it hits another event running parallel that turns the switch off again. Not very clean, wish there was another way to do it.

Original thread: https://forums.rpgmakerweb.com/threads/can-i-make-a-cart-follow-the-rail.42750/