not_quite_sure
Member
Hello,
On the face of it i think this is a pretty simple problem. New to GML so hopefully i just need to call the right function or start to understand the paths bit better.
so this is a top-down game, at times I want to player object to effectively connect to a rail/track, and have limited movement within that rail/track.
prefer to do with code rather than setting up paths as I'm not entirely sure im going to have static tracks/rails in the future. Also, I've seen a few tutorials but paths seem to be very focused on simple enemy/NPC movement rather than setting a rigid course that a player can move up/down/left/right on? happy if someone can show me otherwise and its the path of least resistance..
I've tried the below and this just sets a box that is the sprite width and height from 0,0 for the object to move in.
if rail = true
{
xrailmin = min(o_Rail.sprite_width-o_Rail.sprite_width);
yrailmin = min(o_Rail.sprite_height-o_Rail.sprite_height);
xrailmax = max(o_Rail.sprite_width);
yrailmax = max(o_Rail.sprite_height);
x = clamp(x,xrailmin,xrailmax);
y = clamp(y,yrailmin,yrailmax);
}
if this helps visualize, want the player to move up and down that rail only when rail = true.
Also, this is just a straight line on 1 axis.. looking for it to work when on curves and obtuse/acute angle changes.. i guess think the rail/conveyor system in Factorio
Thanks
On the face of it i think this is a pretty simple problem. New to GML so hopefully i just need to call the right function or start to understand the paths bit better.
so this is a top-down game, at times I want to player object to effectively connect to a rail/track, and have limited movement within that rail/track.
prefer to do with code rather than setting up paths as I'm not entirely sure im going to have static tracks/rails in the future. Also, I've seen a few tutorials but paths seem to be very focused on simple enemy/NPC movement rather than setting a rigid course that a player can move up/down/left/right on? happy if someone can show me otherwise and its the path of least resistance..
I've tried the below and this just sets a box that is the sprite width and height from 0,0 for the object to move in.
if rail = true
{
xrailmin = min(o_Rail.sprite_width-o_Rail.sprite_width);
yrailmin = min(o_Rail.sprite_height-o_Rail.sprite_height);
xrailmax = max(o_Rail.sprite_width);
yrailmax = max(o_Rail.sprite_height);
x = clamp(x,xrailmin,xrailmax);
y = clamp(y,yrailmin,yrailmax);
}
if this helps visualize, want the player to move up and down that rail only when rail = true.
Also, this is just a straight line on 1 axis.. looking for it to work when on curves and obtuse/acute angle changes.. i guess think the rail/conveyor system in Factorio
Thanks