G
Genjira
Guest
Hello.
I want to force the user to hit space each time they want to jump so they can't just keep space pressed down to carry on jumping. I thought keyboard_clear(vk_space) would do that but it doesn't seem to have any effect. If I hold the space bar down, the player object just keeps jumping. My code is in the player object step event:
Am I misunderstanding how (or when) keyboard_clear works?
I've tried using keyboard_check_direct(vk_space) but that doesn't pick up every key press.
Thanks in advance.
I want to force the user to hit space each time they want to jump so they can't just keep space pressed down to carry on jumping. I thought keyboard_clear(vk_space) would do that but it doesn't seem to have any effect. If I hold the space bar down, the player object just keeps jumping. My code is in the player object step event:
Code:
var t1 = tilemap_get_at_pixel(tilemap,bbox_left,bbox_bottom + 1) & tile_index_mask;
var t2 = tilemap_get_at_pixel(tilemap,bbox_right,bbox_bottom + 1) & tile_index_mask;
if (t1 != 0 || t2 !=0) // i.e. on the ground (using the GMWolf Tilemap Collisions technique)
{
if (keyboard_check(vk_space))
{
keyboard_clear(vk_space);
// set various jumping variables...
}
}
I've tried using keyboard_check_direct(vk_space) but that doesn't pick up every key press.
Thanks in advance.