0 Favourites

Player movement with inertia?

  • 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?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)