using clamp with timedelta?

This forum is currently in read-only mode.
  • Hey, I set up my own platform behavior using the custom movement behavior, with the gravity (jumping and falling) using the clamp expression. Works really nice except when the framerate drops you jump super high and fall super slow... I assume this is because the clamp expression is running on ticks or milliseconds, and not timedelta...

    I'm not sure how to set it up to do so... any suggestions?

  • I'm not sure how you've set up your math. In general, clamp the un-timedelta'd (yeah what a word) values and apply timedelta afterwards. For example, if you'd like to have a gravity value between 100*TimeDelta and 200* TimeDelta, it should read

    clamp(undelta'd gravity value, 100, 200) * TimeDelta

  • Okay, what I have set up is when player is in the air...

    clamp(Yspeed+15,-1000,1000)

    When I tack on the *TimeDelta at the end it completely stops movement... is there something I am missing with TimeDelta? I also have this issue when using the wait object, and instead of having it wait 1000 milliseconds, I want it to wait 1000*TimeDelta and it just goes instantly...

    I suppose I just need someone to explain TimeDelta a bit more clearly...

  • I google timedelta and found this from that thread.

    Don't think too complicated.

    So you want two objects with different distances to destinationX to reach that point at the same time. lerp is perfect for that, because wherever you start, as soon as the t-value reaches 1, both will be at destinationX. All you need to do is raising the t-value from 0 to 1 over the period of time you want.

    If you want a number to grow over time, you add n * timedelta to it. The maximum value of t is 1.0. How long do you want it last until 1.0 is reached? 'n * timedelta' equals 'amount per second'

    To have it last 2 seconds, you'd add 0.5 * timedelta (2 * 0.5 = 1)

    To have it last 5 seconds, you'd add 0.2 * timedelta (5 * 0.2 = 1)

    etc.

    + some condition

    -> myT = myT + 0.5 * TimeDelta

    -> lerp(object1.x, destinationX, myT)

    -> lerp(ScrollX, destinationX, myT)

    Just make sure, myT isn't raised anymore, after 1.0 is reached.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • clamp('changing value' + 100 * timedelta, 0, 1000)

    changing value will have 100 added to it every second, so it will take 10 seconds to hit the maximum.

  • Steven, thank you for drawing that out for me-- I think my problem was more a syntax issue than not being able to grasp TimeDelta!

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