I'm making a 2d platformer and I seem to have problems with making a grab move
this is my code:
function player_grab(){
grab_time = 20
state = 5
if (state == 5) && (grab_time > 0) && (!place_meeting(x + hsp,y,obj_solid))
{
sprite_index = spr_player_grab
hsp = (image_xscale * 8)
grab_time--
}
else if (state == 5) && (grab_time > 0) && (place_meeting(x + hsp,y,obj_solid))
{
grab_time--
sprite_index = spr_player_grabwall
vsp = -3
}
else
{
state = last_state
grab_time = 0
}
}```
the error is, I made a grab_time variable to limit the duration of the grab, but instead it stays stuck at 19 instead of dropping down to 0 and stop the grab