using clamp with timedelta?

For questions about using Classic.

Post » Mon Jun 25, 2012 7:41 am

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?
B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Mon Jun 25, 2012 8:08 am

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
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Jun 26, 2012 7:09 pm

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...

B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Tue Jun 26, 2012 7:18 pm

I google timedelta and found this from that thread.
[QUOTE=tulamide]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.[/QUOTE] zyblade2012-06-26 19:19:03
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Wed Jun 27, 2012 12:25 am

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.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Wed Jun 27, 2012 6:02 am

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!
B
5
S
1
G
2
Posts: 99
Reputation: 1,575


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests