L
LCM
Guest
Hi!
So I'm working on a platformer and just finished programming moving plateforms. Problem is, especially with platforms moving up and down, my player object gets stuck in the platform and I can't move my player anymore.
Looking at my code, I guessed why it happens, but can't find a way to make it function. So I'd really appreciate it if someone could teach me how to do it!
Thanks for reading!
Here's the code:
So I'm working on a platformer and just finished programming moving plateforms. Problem is, especially with platforms moving up and down, my player object gets stuck in the platform and I can't move my player anymore.
Looking at my code, I guessed why it happens, but can't find a way to make it function. So I'd really appreciate it if someone could teach me how to do it!
Thanks for reading!
Here's the code:
GML:
if (place_meeting(x + hsp, y, obj_MovingPlatform))
{
while (!place_meeting(x + sign(hsp), y, obj_MovingPlatform))
{
x = x + sign(hsp);
}
hsp = 0;
hsp_frac = 0;
}
if (place_meeting(x, y + vsp, obj_MovingPlatform))
{
while (!place_meeting(x, y + sign(vsp), obj_MovingPlatform))
{
y = y + sign(vsp);
}
vsp = 0;
vsp_frac = 0;
}
if (place_meeting(x, y + sign(vsp), obj_MovingPlatform))
{
with (obj_MovingPlatform)
{
other.x += hsp;
other.vsp = vsp;
}
}