Natural deceleration when key depressed

Greetings, everybody!

I’m working on a new game, and I would appreciate any input you have for my situation.

In the game, the player uses a bicycle to move. What I’m trying to do is set up the movement so that, when a direction key is pressed, the bicycle employs a natural acceleration, and when the key is depressed, the bicycle will employ a natural deceleration.

What I set up originally was an object variable to represent the bike’s speed, and that the variable coincides with the pixel speed for object movement. I then set up an event where, if the direction key is released but the object variable is greater than zero, that the object movement kicks in in the opposite direction of the current movement, to simulate a slowing down and eventual stop of the bike. Obviously, this was without success.

I’ll attach a screenshot. I would appreciate any input from anyone who has actually set something like this up. I’m going to try to play with it a bit more today, but any help on this would be appreciated

For something similar I multiply the current velocity for 0.9, you may try with 0.97.

I use the Physics 2.0 extension (here’s the wiki) and access the Linear Velocity parameter, but I guess you can insert my logic in your code without installing the extension.

Sorry to be finicky, but depressing a key is not the opposite of pressing a key (English is a funny, inconsistent language). To depress something is to press down on it. I think you mean when a key is not pressed.

The Left key is released condition is a one off, and triggers the first time the key is released. It’s doesn’t mean the key isn’t being pressed. Instead you want to use an inverted Left key is pressed condition :

Thank you, gentlemen. I shall try your options tomorrow and report back!