• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

How to Move an Object that is Following a Relative Path?

For instance, I have a game with an auto scrolling camera, and I want to have an enemy appear and stay on screen while following the same speed as the auto scrolling camera. But, with the normal relative path function, the object just stays where it's at following the path no matter if I put y -= 1 in the object's Step Event.

For example, if an object is following a relative path in a circle, how can I keep the object on screen following the auto scroll and stay on it's path?
 

TheouAegis

Member
I think if you use the built-in path functions, you'd have to move the path itself. And at least back in GMS1.4, this was a tedious process of saving the path position, stopping the path, moving the path, starting the path, then moving to the saved path position. Especially if your path was marked as "absolute". Not sure if that has changed in recent versions or if using relative pathing behaves differently.
 

Yal

šŸ§ *penguin noises*
GMC Elder
When an object is on a path, it will be teleported to an appropriate position on that path every time the path position increments. "relative" just refers to if you start the path from your current position (as opposed to wherever the start point of the path is defined in the editor), it's intended for things like separate "turn left" / "turn right" paths for an AI character.

Easiest solution here would be to move the object yourself, using path_get_x / path_get_y to get path coordinates and then applying them on top of your other movement.
 
When an object is on a path, it will be teleported to an appropriate position on that path every time the path position increments. "relative" just refers to if you start the path from your current position (as opposed to wherever the start point of the path is defined in the editor), it's intended for things like separate "turn left" / "turn right" paths for an AI character.

Easiest solution here would be to move the object yourself, using path_get_x / path_get_y to get path coordinates and then applying them on top of your other movement.
Thanks for the reply. I was reading about the path_get_x / path_get_y functions, but they don't seem like what I want to do. Here is an example of the kind of movement I'm trying to do with Paths.


This is a gameplay video of TwinBee, where it appears that the camera is moving (or it could be just a scrolling background), but when the enemy ships appear on screen, they appear to be following a path and they also are keeping up with the same speed as the scrolling screen if it is a moving camera.
 

TheouAegis

Member
Okay here's the thing. Twin Bee wasn't made in Game Maker. It did not use GM"s paths. With that said, there were two methods you could use. The first is to keep using paths, but move the path every step as I described previously. Or you don't use paths and code enemy movement with timeliness or a state machine (which is what a timeline basically is) then add the scroll speed to all enemies.
 
Okay here's the thing. Twin Bee wasn't made in Game Maker. It did not use GM"s paths. With that said, there were two methods you could use. The first is to keep using paths, but move the path every step as I described previously. Or you don't use paths and code enemy movement with timeliness or a state machine (which is what a timeline basically is) then add the scroll speed to all enemies.
Well, I know TwinBee wasn't made in GameMaker Studio 2. I was just using as an example that it looks like their are using a "path style system".

I've tried moving the Object in it's Step event using y -= 1 since the Path I'm using is Relative to the Object's position. I haven't used Path very much. Just in the basic way, so I don't currently understand all of of their functions.

I haven't been using Timelines either.
 

TheouAegis

Member
They more likely used a timing system, similar to timelines. It's essentially a finite State machine. Basically, you have a state variable set to 0 initially. Then you have a pattern array basically set up as
[time, hspeed, vspeed]
You set a timer (e.g., an alarm) to the first value, hspeed to the second, and vspeed to the third. You count down the timer, when it hits 0, increase that state variable and then use it to get the next set of data in the pattern array. This is how they did it in Gyruss (also a Konami game) and the sun in Super Mario Bros 3.
 
Top