# How do I use unlerp?

Get help using Construct 2

### » Sat Dec 19, 2015 3:30 pm

I was trying to use lerp to increase my Sprites Opacity to 100 if it started from 25 like this:

lerp(Self.Opacity, 100, 9.8 * dt)

how do i do this if I want to decrease opacity using lerp? or do I have to use unlerp? But I don't know how to use unlerp. Can anyone explain how I can achieve this?
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
70
S
23
G
91
Posts: 1,143
Reputation: 60,766

### » Sat Dec 19, 2015 4:17 pm

Just change the target value, 100 to 0
B
172
S
50
G
189
Posts: 8,505
Reputation: 118,729

### » Sat Dec 19, 2015 4:57 pm

newt wrote:Just change the target value, 100 to 0

I mean change the opacity to a lesser value smoothly by 9.8 * dt using lerp or unlerp
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
70
S
23
G
91
Posts: 1,143
Reputation: 60,766

### » Sat Dec 19, 2015 5:18 pm

The same mechanism you used to raise the value.
lerp(Self.Opacity, 0, 9.8 * dt)
B
172
S
50
G
189
Posts: 8,505
Reputation: 118,729

### » Sat Dec 19, 2015 6:07 pm

Tried that, doesn't work. I also tried doing negative with b :/
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
70
S
23
G
91
Posts: 1,143
Reputation: 60,766

### » Sat Dec 19, 2015 6:47 pm

chadorireborn wrote:I also tried doing negative with b :/

I'm not sure what you mean by this..
The above expression by @Newt should work..

What are the conditions of the event to which the set opacity action is attached?
Could there be conflicting events?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Sat Dec 19, 2015 7:13 pm

LittleStain wrote:
chadorireborn wrote:I also tried doing negative with b :/

I'm not sure what you mean by this..
The above expression by @Newt should work..

What are the conditions of the event to which the set opacity action is attached?
Could there be conflicting events?

Yeah. You are right there were things that conflict. I'll try to fix it.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
70
S
23
G
91
Posts: 1,143
Reputation: 60,766

### » Sat Dec 19, 2015 7:13 pm

newt wrote:The same mechanism you used to raise the value.
lerp(Self.Opacity, 0, 9.8 * dt)

Thanks it works.
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
70
S
23
G
91
Posts: 1,143
Reputation: 60,766

### » Sat Dec 19, 2015 7:23 pm

But what does unlerp really do?
The Things you can create is only limited by your imagination. If you don't have the skills then use your motivation as a natural force to exceed all expectations. Chadori RebornXD
B
70
S
23
G
91
Posts: 1,143
Reputation: 60,766

### » Sat Dec 19, 2015 8:23 pm

lerp(0,100,0.5)=50
unlerp(0,100,50)=?

You can use it to find out the percent something was interpolated.
B
172
S
50
G
189
Posts: 8,505
Reputation: 118,729

Next