Acceleration\Inertia & Animation speed control

Hello. It’s me again with my newb questions. I have simple scene with boat object and parented to it propeller object. What do i need - i want boat slowly increasing speed up to defined value on pressing key (up arrow), also i need propeller object playing “turn” animation increasing it’s speed to defined value. And after up arrow key is released boat should slowly stop moving (intertia effent) and propeller should slow down animation. What i did. I found exapmle in BGE Resource thread on this forum with script controlling animation speed, and adopted that example to my scene. Now propeller is working as i wish. But problem is boat moving. I can’t find the way to make it accelerate and stop smoothly. I found some tutorial how to use properties (with logic bricks) to control movement speed but in the end it worked like step increasing\decreasing speed (not smoothly) so i think it needed some Python scripting to make boat increase\decrease speed smoothly. I will appreciate any help. Only one thing i want to keep script as simple as possible. I don’t need any complex physicly based systems like many is using for car setups. Just simply increasing\decreasing speed of movement ruled by property “speed” of my boat object. Here is my blend scene:


ActionSpeed&AccelerationControl.blend (401 KB)

just use other property settings

property - less then 1.0 -> and -> motion
keyboard --------------------/
---------------------------------------\ property - add +0.05

so you hold the key and property speed is less then 1 it will activate and add 0.05 to the speed property.

to reduce the speed property:

property - bigger then 0.0 -> and -> property - add -0.05
keyboard - inverted ----------/

so when you release the key it will reduce the property by 0.1

with python its a bit easier to control everything but can be harder to setup.
i made a movement script with a jetpack function years ago, take a look at the blend: (yes it’s still working in 2.79)

It should not be hard to figure out how you can use/write it, in scroll down to the comment #jetpack
there you see the handful of code used to (de)accelerate etc.

This answer is free, and is regarded as an extended reference to BGE (forgive me, we have such Laws)
Hi there.
I passed by, and decided to help.

Only one thing i want to keep script as simple as possible.

  • like it turned out to be maximally simple, in the script there is a description of everything. With Logical Bricks, for example, it’s more difficult for me to work.

I return to you your file - ActionSpeed&AccelerationControl.blend (957 KB)

Good luck in your creative work.

Thank you guys very much for your help. You are helped me a lot with simple and clear scripts and detailed coments. Now I have made one more step to understanding Python logic. I will use your scripts in my little arcade game/ They are working great and they are easy to edit.

And yes, lot of logic bricks i had on my scene objects (boat and propeller) now are replaced with only one script. Thats looks very elegant and handy - to edit all needed values in one text file. That’s cool.

No problem… :rolleyes:
If the topic is solved - write in the beginning SOLVED, please.