Infinite Car Loop

Hello everyone, I don't know if here it's be the most suitable place to exhibit this doubt.
 







I wonder how I can create an endless loop of cars moving on a road,
My road has 150 tiles and it goes on one single direction without any turns.
Do I have to create an event "move left" 150 times +  "transparent ON"  + "move right" 150 times + "transparent OFF" and repeat the process? 
Or can I program so it goes left until it can't go any further and transfer it to the starting point?

Someone who has had the same problem and has been able to solve?

😀  Thank you  😀
you probably mean that your road has 150 tiles, not 150 pixels.


There are several ways to handle this, but the easiest is probably to make the move left 150 times and then use a "set position" to get back to the start.


If you make a repeating move left only, then you would need a parallel process for checking the position of the car and setting the position back once its at the end.


That would be more effective, but it is also more difficult to set up correctly.
you probably mean that your road has 150 tiles, not 150 pixels.


There are several ways to handle this, but the easiest is probably to make the move left 150 times and then use a "set position" to get back to the start.


If you make a repeating move left only, then you would need a parallel process for checking the position of the car and setting the position back once its at the end.


That would be more effective, but it is also more difficult to set up correctly.

Thank you very much
Let an Event use Eventcommand Set Move route, choose a EventID that will be a car and do the following


Move Right


Scriptsnippet: if $game_map.events[@id].x == ($game_map.width - 1) ; moveto(6 , 10) ; end


Explanation:


$game_map.events[@id].x  = Map X of this Event


($game_map.width - 1) = Map width 18-1 = 17 or whatever size your map got.


moveto(6 , 10) = Teleport this Event to mapx, mapy. there was also a command to teleport it back to its origins.


But your event would not move totally fluid, thats why i would recoment to make the condition if car is at mapend in another paralell event and not in the autonomous moveroute. But test for yourself. If you enter


move right than scriptline, 4 times or more the event moves a little more fluid cause of preloading or whatever 🙂.
I think that having it Move 150x will basically cause it to eventually move too far away from the screen and therefore stop moving (not 100% sure but I believe RPG Maker does stop events from moving once they're about 20 tiles away from the screen), meaning that it will never reset unless you have the player follow the car.  These kinds of things work well in confined spaces, not so much in wide spaces.


The best way to handle it in a wide space would probably be to have the game detect when the car is offscreen and reset the car to a place just to the right of the screen at that point.  This requires intermediate to advanced coding so I won't go into it here, but if it's something that you absolutely need to do for your game, you should learn about it in the "Learning JavaScript" subforum.
If the Moveroute is given once by an Event to an Event , the Event will continue driving around even if far away from visible Screen.


Some Anti-Lag Scripts may prevent this but have there own Workarounds to archieve the wanted.


A 150 Steps Moveroute would crash i asume, if i remember correct about old Forum topics, but iam not total sure.


This Topic is interesting playing around with Cars is fun, no matter if Lego, Match Box or RPG Maker pixel Cars 🙂.


The hardest part in my Opinion is to let the Car driving outside of the Screen, because without Workaround like 1 Black row of black


Maptiles on above (Star Passability) at the Mapends, i dont know any other Way to make it driving outside the Mapend without just turning invisible at Mapend.


Sorry my english aint the best.
Is there anyway to create the event to appear only on the screen, so the lenght of the 150 tiles event won't crash. The car event would disappear when it would be like 4 tiles on the left on the screen and then be moved to 4 tiles away to the right so it would move through the screen again??


Thanks
Maybe someone else can help you or Links you a final solution.


I cant,


because my english aint the best and i cant translate and bring to meaningfull context, less than half of your last post.


And me asking you stupid question for every detail, nah i thought ^^ let the Profis handle the Help this Time. Good Luck

Original thread: https://forums.rpgmakerweb.com/threads/infinite-car-loop.67704/