Lerp opacity?

Get help using Construct 2

Post » Mon Aug 06, 2012 7:44 am

You don't need lerp to gradually change the object's opacity. Just do this:

Showercover.opacity = clamp( Showercover.opacity + speed*sign*dt,0,100)

- sign is just a variable should hold a signed number 1 (1 or -1) to affect which way the opacity should change
- speed is to control how fast it fades (5 is slow-ish)
Oh, and clamp is there to make sure it stops at 0 or 100.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon Aug 06, 2012 8:00 am

[QUOTE=DoubleElite] I always thought lerp returns a value, not changing a value. I thought it takes A and B, and uses C to pick a spot between the two. Going from 0(A) to 1(B). So if I set lerp(0,100,5*dt) to run every tick, why wouldn't it work? I', sorry if I'm not getting it. If you don't want to explain it anymore, no worries. :)[/QUOTE]

I think you're confused about what dt does.
Dt is the time since the last tick, and will stay the same as long as the frame rate is constant.

Also you might take a look at the fade behavior.

Also comparing the last value as a component of time isn't exactly correct, in that it only effects time because of the amount that it adds each tick, IE 5*dt would add less than 20*dt. newt2012-08-06 09:01:03
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Mon Nov 16, 2015 8:03 pm

I use this in objet that need fade opacity : Self.Opacity-(100*dt) and after un wait system 0.3 and destroy object. Is cool when player kill enemy and work very prerry.
B
5
Posts: 32
Reputation: 297

Post » Mon Nov 16, 2015 8:21 pm

yfchild2 wrote:I use this in objet that need fade opacity : Self.Opacity-(100*dt) and after un wait system 0.3 and destroy object. Is cool when player kill enemy and work very prerry.


And the reason for bumping a 3 year old thread with that remark is??
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Previous

Return to How do I....?

Who is online

Users browsing this forum: Artpunk, Kagubro, Mirlas, zeneizel and 26 guests