# How do I make smooth properties transitions ?

Get help using Construct 2

### » Tue Feb 03, 2015 5:40 pm

Hi !

Let say I want to make the opacity of my sprite from 100 to 50 in 1 second.

I just want to specify the base value, the final value, and the duration, so the transition will be as smooth as possible and I won't bother with events like "every 0.1 sec -> decreases opacity by 5" and stuff.

I guess this is very simple, but I didn't figure out how to do it.
B
12
S
7
G
7
Posts: 447
Reputation: 4,270

### » Tue Feb 03, 2015 6:34 pm

You should read about delta time, but the short version is: if opacity > 50, opacity = opacity - 50*dt
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

### » Tue Feb 03, 2015 8:33 pm

I read the tutorial about dt, but I didn't figured out how to achieve what I want.

Thanks for the short version. How can I add a "duration" parameter to this ?
B
12
S
7
G
7
Posts: 447
Reputation: 4,270

### » Tue Feb 03, 2015 8:40 pm

It's good to learn how to do it from first principles, but you could also use the Tween or LiteTween plugin.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Tue Feb 03, 2015 9:06 pm

Coin-coin le Canapin wrote:I read the tutorial about dt, but I didn't figured out how to achieve what I want.

Thanks for the short version. How can I add a "duration" parameter to this ?

dt is your time - every second it will add up to more or less 1 - so if you do something like Value + dt*50 - within one second that value will go up by ~50. If you do dt*25 then it will take 2 seconds and so on.

Just understand that there's no limit to it, hence the "If value >50" in my example, otherwise if, for example you do an "Every tick" condition it'll just endlessly add 50 every second. Which is one reason why the Tween plugins mentioned by codah are pretty neat.
B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

### » Tue Feb 03, 2015 10:05 pm

I currently use litetween but I thought it would be cool if I made it from scratch (sort of).
B
12
S
7
G
7
Posts: 447
Reputation: 4,270

### » Tue Feb 03, 2015 11:06 pm

Maybe you should check out lerp (ease out) and cosp (ease in and out) functions.
Also mind anglelerp for easing angle rotation.

https://www.scirra.com/manual/126/system-expressions

See my example. It is really easey Hope it helps.
You do not have the required permissions to view the files attached to this post.
B
8
S
3
Posts: 197
Reputation: 1,207

### » Tue Feb 03, 2015 11:22 pm

Thank you very much, that's pretty much what I want to achieve (basically, triggers Fade 1 or 0 on any event).
B
12
S
7
G
7
Posts: 447
Reputation: 4,270

### » Tue Feb 03, 2015 11:35 pm

Thought so, you are welcome!

Btw, I just wanted to post a problem with some lerping on rotation, when I took a look at the manual about your issue, and found anglelerp solving my problem So thanks for your question
B
8
S
3
Posts: 197
Reputation: 1,207

### » Wed Feb 04, 2015 10:58 am

MultipleChoice thanks I was wondering how to do that. See everyone learn something new everyday
B
213
S
29
G
14
Posts: 1,867
Reputation: 36,970

Next