• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Movement input - not sure what to call it.

Is there a gml function that'll work with keyboard inputs so that if the user just taps the right key for example, the player animation will run one sprite animation that accommodates for the short frame length, and then if that same key is held for a duration of time, a different animation sprite is used instead?

I only ask because I don't know what to search for as I can't think what to call this ha.

The purpose behind this is because my player object is a guy in a wheelchair I'd like to achieve small movements with one animation and longer movements with a different animation.

So the logic would be something like
Code:
If (keyboard_check(vk_right) is held
for more than 1/4 of the sprite pixel size {
sprite_index = sprite long animation
} else {sprite_index = sprite short animation;}
Say the player sprite pixel size is 32x32, 1/4 would be 8 pixels. So if moving right will be greater than 8 pixels ... And so on.

I was able to speed up the same animation of the normal movement when the movement speed increased, such as holding the shift key. I've created a new animation for short distances, like one tap of the key sort of distances. Basically three frames of animation instead of 8.

So even a tap of the key would force the player to move 3 frames of distance as obviously I could get less than 1 frame if I'm tapping super quick.

If it isn't a gml function per say I'm guessing some sort of timer variable or a variable that counts pixel movement from point a to point b. Or if I can choose 3 frames out of the 8 total frames in the sprite to animate only, that would mean I could remove the short animation sprite. Choices choices haha.

As usual not after spoonfed answers just some helpful guidance đź‘Ť
 
Last edited:

TheouAegis

Member
If the dash Sprite and the run Sprite have the same starting frames, then put those starting frames as one separate sprite. When the direction key is pressed, switch the sprite to that initial animation. At the same time, set a variable to true. when the key is released, set the variable to false. In the animation end event, check if you are currently using the startup sprite, then check if that variable is still true. If it is true, switch to your running Sprite and set the variable to false; else if it's false, switch to your dash.
 
Last edited:
Top