The aim is for the player object to slow down and stop instead of just stopping dead. The following codes works ok when the player is not jumping, but gets stuck in an object if the player is in the air when they do it.
Left key released event:
if hsp = 0 exit;
hspeed = -3;
friction = 0.20;
if obj_Player.hspeed = 0
{
hspeed = 0;
}
Right key released event:
if hsp = 0 exit;
hspeed = +3;
friction = 0.20;
if obj_Player.hspeed = 0
{
hspeed = 0;
}
Horizontal collision code for interest:
if (place_meeting(x+hsp,y,obj_bound))
{
while(!place_meeting(x+sign(hsp),y,obj_bound))
{
x += sign(hsp);
}
hsp = 0;
}
x += hsp;