M
MaxHP43
Guest
I have been using this tutorial by Yoyo led by Shaun Spalding:
I tried a more advanced platformer tutorial by him and got an issue where my player lands halfway through the wall object rather than sitting nicely on the top of the object, and it also keeps the player in the falling image rather than the standing animation. I figured I did something wrong with the collision mask, or the use of Place_meeting vs position_meeting, so I tried the basic platformer tutorial above. However, using the exact same code and assets as Shaun, I get the same result.
I have tried moving the origin around and get different results. If the origin is in the very top left, beyond the collision mask, the play sits somewhat on top and plays the standing animation like normal, although the player does clip a little into the wall below. Moving the origin to the very bottom make the player land even further down into the wall object.
If I remove the last part of the code //animation then the collisions and standing animation works perfectly.
Did something change in GM2 that the tutorial is missing?
I tried a more advanced platformer tutorial by him and got an issue where my player lands halfway through the wall object rather than sitting nicely on the top of the object, and it also keeps the player in the falling image rather than the standing animation. I figured I did something wrong with the collision mask, or the use of Place_meeting vs position_meeting, so I tried the basic platformer tutorial above. However, using the exact same code and assets as Shaun, I get the same result.
I have tried moving the origin around and get different results. If the origin is in the very top left, beyond the collision mask, the play sits somewhat on top and plays the standing animation like normal, although the player does clip a little into the wall below. Moving the origin to the very bottom make the player land even further down into the wall object.
If I remove the last part of the code //animation then the collisions and standing animation works perfectly.
Did something change in GM2 that the tutorial is missing?
GML:
//get player input
keyleft = keyboard_check(vk_left);
keyright = keyboard_check(vk_right);
keyjump = keyboard_check_pressed(vk_space);
//calulate movement
var _move = keyright - keyleft;
hsp = _move * walksp;
vsp = grv + vsp;
if (place_meeting(x, y+1, owall)) and (keyjump)
{
vsp = -jumpsp;
}
// horizontal collision
if (place_meeting(x+hsp, y, owall))
{
while (!place_meeting(x+sign(hsp),y,owall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
// vertical collision
if (place_meeting(x, y+vsp, owall))
{
while (!place_meeting(x,y+sign(vsp),owall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
// animation
if (!place_meeting(x,y+1,owall))
{
sprite_index = splayerjump;
image_speed = 0;
if (vsp > 0) image_index = 1; else image_index = 0;
}
Last edited by a moderator: