How do I Calculate this position X

0 favourites
  • 5 posts
  • Hi, I have a sprite with platform behavior.

    Maximum speed 60

    Deceleration 240

    I need to figure in which X coordinate will brake the sprite completely when I do not press any key.

    I mean, I need to calculate in advance the X that the sprite will have when it stops completely.

    What calculation do I have to do with the maximum speed and braking speed?

    The acceleration is instantaneous (10000) so I do not take it into account. But if you know the calculation also with the acceleration, then I could alter this and use your calculation to help me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Stopping distance would be = (speed^2)/(2*deceleration)

  • Here's a cheat.

    The deceleration is always constant. So assuming your actual moving speed is always the same (like you said), the braking distance is constant, too. You can actually measure the braking distance by capturing the X position of the Sprite when the key is released, and then capturing the X position again when the Sprite stops.

    EDIT: whoops, looks like R0J0hound's got the legit answer.

  • Thanks guys, the formula of R0J0hound works perfect.

    But ... why is it multiplied by 2 and not by another number?

  • the Mnk

    The Formula for braking distance is Sb=V²/2*a with V for the velocity and a for the deceleration

    The velocity over braking time is:

    v(t) = V - a*t

    The distance over time:

    s(t) =V*t-0.5*a*t²

    Now you have to know how long the braking takes :

    v(t)=0

    => 0 = V-a*t

    <=> t = V/a

    with s(t) =V*t-0.5*a*t² and t=V/a

    => S= V*V/a-0.5*a*V²/a² = V²/2*a

    (speed^2)/(2*deceleration)

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