Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: WiseFrog on Sun 02/05/2021 08:55:18

Title: How to do an action only if key is tapping and other if is pressed all the time
Post by: WiseFrog on Sun 02/05/2021 08:55:18
First of all hi to everyone, I'm new around here hahaha. After a long time of experimenting with ags and helping a friend with his games, I decided to start a personal project and also took the opportunity to register on the forum.

I'm trying to make a game that uses the keyboard to walk (I'm using eri0's controlz module). The problem is the following: when you keep the keys pressed, the character walks perfectly well and fluidly, but if you decide to just tap the keys, you can notice that the character makes huge jumps during the walk. Investigating I notice that this can be solved by changing the character speed to 1 for example, then in that way the walking tapping works perfect and fluid but it is incredibly slow if the key is pressed all the time so the character can walk for a longer time. I tried to fix it with on_key_pressed but it changes the speed to 1 all the time and not just when it is tapped.

My question is: is there any way that the character speed is 1 only if the key is tapped but 4 (for example) if it is pressed all the time?

Thank you so much in advanced
Title: Re: How to do an action only if key is tapping and other if is pressed all the time
Post by: eri0o on Sun 02/05/2021 12:47:20
Hi WiseFrog!

Have you tried on your character, disabling the anti-glide? If you click the character on the AGS Editor, in the properties panel, look for the option MovementLinkedToAnimation and try setting it to false.

Also the character MovementSpeed and AnimationDelay have different meanings when MovementLinkedToAnimation is either true or false, so I would recommend still playing a bit with those values.

Also setting your game speed to 60 (ags defaults to 40) usually helps too.
Title: Re: How to do an action only if key is tapping and other if is pressed all the time
Post by: WiseFrog on Sun 02/05/2021 22:57:56
Quote from: eri0o on Sun 02/05/2021 12:47:20
Hi WiseFrog!

Have you tried on your character, disabling the anti-glide? If you click the character on the AGS Editor, in the properties panel, look for the option MovementLinkedToAnimation and try setting it to false.

Also the character MovementSpeed and AnimationDelay have different meanings when MovementLinkedToAnimation is either true or false, so I would recommend still playing a bit with those values.

Also setting your game speed to 60 (ags defaults to 40) usually helps too.

Hi Eri0o. I did what you said and it works perfectly, now it's more fluid and the character doesn't make terrible jumps on the tapping walk. Thank you very much