Legacy GM "Detecting Collision" with Paths; Possible?



I'm creating a top-down rail shooter where the player has the ability to jump from one rail to another. The rails are all generated with paths for simplicity's sake on my part.

My original solution was to have invisible objects ride along the paths, and have the player snap to those objects instead of the actual paths. When the player pressed left or right, the player would do a 180-degree scan (from the front to the back, going left for left and right for right) to search for these invisible railRider objects. If a railRider was found, the player would snap itself to it. For a while this solution worked during testing and prototyping, until I began to work on some of the actual levels I had planned. With more complex and varying paths, this system just does not work as intended, though not because of any bugs.

The second solution I considered was to use a separate surface along with draw_getpixel. On this separate surface, the map would be identical, but rather than drawing the graphics the player (the human, not the object) will see, the paths would be drawn alongside blocks, pixels, and other shapes for the objects. The game would take the player's position and angle, and then check every pixel along a set length to find another path. From what I've read from the documentation, draw_getpixel is very slow and shouldn't be used as frequently as I would be. I don't want to have spent numerous hours on this solution (considering how little time I have to devote to game dev'ing) only to find out it slows down the game; my goal is to have this game run at a consistent 60FPS on a Samsung Galaxy S4 Android with dozens of objects on screen at a time.

So, all that being said finally brings me to my question(s):
- Considering paths lack any sort of collision, is there a way to fake collision detection for them?
- If anybody can speak from experience, am I already on the right path with my second solution and is it actually not going to slow down my game that drastically on a mid-end smartphone?
- Am I being stupid and should use something other than paths?

Not looking for people to do my code for me, just some suggestions.


Hi, you can try looking into the functions path_get_x and path_get_y. with these you can check your objects x position with the y point of the path at your object's x position or vice-versa, that should give you the info you need to snap your object to it if within range

Someone had asked me this question before and I made a .gmz example, i just found it here's the link to it: https://drive.google.com/open?id=0B4uEFC9Ii8BnbjdVc3V5Y2V4bTg
It's purposly made with 10 rediculously large backgrounds and it takes 40 seconds to load the game but it shows how you can take every background, draw 64x64 clods of grass lined up on each rooms path, save the new background with the grass positioned correctly on the path and then loads the new background. (and yep, that's me in my old 87 monte ss hahaha) You don't need to use the room copier/item placer background replacer code so it is lightning fast if you are just checking where the path is relative to your object and doing some resulting code from the results. Hope this helps!
Last edited by a moderator:


Friendly Tyrant
Forum Staff
A fairly cheap and quick way to test is simply to loop through the path points and do a collision line between each of them. If the path is not curved then this will work perfectly, but if it is curved you may get some odd results, but id the curve isn't too pronounced then it could still work well enough to use...