How do I smoothly ramp an effect parameter value?

Get help using Construct 2

Post » Thu Oct 13, 2016 12:06 pm

Hi, I'm wondering how I to ramp value so that it moves smoothly from, for example, 1 to 100, rather than just an abrupt jump from 1 to 100.

Specifically, I want to blur the title text of my game on the start menu once the player selects "start". The title text has the BlurVertical effect on it, I can trigger it to jump from 0.1 to 100, is there a way to make the effect ramp to the higher value?

thanks,

Matt
B
7
S
1
Posts: 23
Reputation: 421

Post » Thu Oct 13, 2016 4:12 pm

I've used Groups to deal with such:

Group "BlurIn" (disabled at start)
-every tick/x seconds -> set blur effect to blur effect plus x
-If blur effect > 100 disable Group "BlurIn"

Then when you want it to blur just set the group to be enabled. Can make another group that does the opposite.
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913

Post » Thu Oct 13, 2016 4:33 pm

@Donic Dawkins

Alternatively, for an eased effect, you can create a global variable called BlurValue and set it to 0. Create an instance variable on your text object BlurOn with a value of 0. Add these events:

On "Start" object clicked => set text.BlurOn to 1
If text.BlurOn = 1 => set text effect parameter to BlurValue, set BlurValue to lerp(BlurValue,100,1-0.3^dt)

I hope this helps
B
16
S
9
G
5
Posts: 74
Reputation: 4,120

Post » Sat Oct 15, 2016 1:13 pm

HI badmoodtaylor and SimoneT,

Both seems like good approaches, thanks for suggesting. I like the idea of Groups that get turned on/off, and I also like the idea of using the lerp function for easing.

However couldn't get either to work :lol:

Image


badmoodtaylor, I may have the math wrong. I tried it several ways, how would I properly state "BlurEffect plus x"?

SimoneT, not sure what isn't working here. Pretty sure I have my global and instance variables set right, and I copied and pasted your values for lerp.

thanks,
Matt
B
7
S
1
Posts: 23
Reputation: 421

Post » Sat Oct 15, 2016 1:16 pm

In your screen shot your group is disabled. You don't want that—it can't get enabled at runtime. Right click on it, click on edit, un-check "active at start".

Sorry if my terms mislead you—lackadaisically I used 'disabled' instead of 'not active'
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913

Post » Sat Oct 15, 2016 1:21 pm

Event4: You are setting BlurOn to the BlurValue. You need to set the effect value to BlurValue.
ImageImageImage
B
71
S
21
G
221
Posts: 3,649
Reputation: 124,227

Post » Sat Oct 15, 2016 1:45 pm

Here is one with regular blur and text blur—I might like regular better but your preference. You can mess with the speed of the lerp one by changing the "0.08" but make sure you change it in both actions

https://www.dropbox.com/s/h9p6gpi07uisf ... .capx?dl=0
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913

Post » Mon Oct 17, 2016 4:53 pm

Thanks for file badmoodtaylor but can't open as I'm still on the last stable release (r233). I made the group inactive rather than disabled and the effect occurred, but did not ramp to 100, jumped to the highest value.

blackhornet, made the change as you suggested and the code works. Not sure of how to manipulate the lerp values. The manual states this as the definition of lerp:

lerp(a, b, x) Linear interpolation of a to b by x. Calculates a + x * (b - a).


So for my example a = BlurValue, b = time it takes to come to full value (?), and x = amount of blur to add (?).

thanks,
M
B
7
S
1
Posts: 23
Reputation: 421

Post » Mon Oct 17, 2016 6:29 pm

B
33
S
18
G
28
Posts: 2,455
Reputation: 20,874

Post » Tue Oct 18, 2016 1:11 pm

Donic Dawkins wrote:Thanks for file badmoodtaylor but can't open as I'm still on the last stable release (r233)...


Ah, that's really annoying because I only updated to open someone else's capx I was trying to help
ImageImageImage
B
39
S
22
G
11
Posts: 486
Reputation: 9,913

Next

Return to How do I....?

Who is online

Users browsing this forum: stevenode and 10 guests