Player movement with inertia?

Get help using Construct 2

Post » Tue Sep 27, 2016 3:12 pm

Hi all,
I have. a top down game and want to make the player react to movement input (gamepad stick) with a subtle inertia for better sense of weight.

So far instead of applying the actual stick input on the player I'm increasing a variable per axis at a fixed increment when a stick is moved. It works but takes an elaborate switch statement to cap and reset the value per axis.

Can someone recommend a smarter solution?
Posts: 216
Reputation: 1,692

Post » Tue Sep 27, 2016 7:09 pm

Any reason you're not using the 8 direction behavior? It should encompass everything you require. Set acceleration based on your stick axis value.

If you want to do it yourself, from what I understand from your description, you're mostly doing it correctly. You'll need velocity and acceleration variables per axis (x and y I assume). Your input determines your acceleration. Every tick, your acceleration will be added to your velocity. For caps, you'll be using the max() and min() expressions. Given no input (else condition), you will need to subtract a set amount from velocity (or add, if it is already negative) towards 0, which represents deceleration/friction.
Mistakes were made.
Posts: 1,581
Reputation: 60,458

Return to How do I....?

Who is online

Users browsing this forum: DharmaOne and 17 guests