J
JopRillos2001
Guest
Im making a platform game where my character can duck. When he ducks in the air, he performs a groundpound. key_duck is asigned to the 'S' key (not pressed or released). vsp is the vertical speed and duckgrav is the groundpound speed. While performing the groundpound, the sprite should be changed to a duck animation.
Here is the code I use:
if (key_duck) {
vsp = duckgrav;
sprite_index = spr_player_duck;
} else {
//other movement
}
When I try this, the player gets stuck in the air with a duck sprite while I press 'S'.
Once I release the key, the groundpound gets performed, but the sprite goes back to a normal fall animation.
When I tried to change key_duck to a pressed key event, the groundpound works, but without the correct animation (gets reset by default animation). This is the code for the fall and jump animation.
Here is the code I use:
if (key_duck) {
vsp = duckgrav;
sprite_index = spr_player_duck;
} else {
//other movement
}
Once I release the key, the groundpound gets performed, but the sprite goes back to a normal fall animation.
When I tried to change key_duck to a pressed key event, the groundpound works, but without the correct animation (gets reset by default animation). This is the code for the fall and jump animation.
if(vsp < 0) {
image_index = 0;
} else {
image_index = 2;
}
image_index = 0;
} else {
image_index = 2;
}