Smoothly increase a float value on key press

Hi all,

I am working on this problem, where a parameter in my MPC is driven by a float value. I want my float value to go from 0 to 1 smoothly, with .1 increments when the “f” key is pressed.

For the sake of clarity, let 0 represent blue and 1 represent red. The idea is on keypress, we go .1 closer to red, smoothly and it would take 10 pressed of “f” to move from red to blue.

I have tried adding the current float value with the .1 increment but I ditched that because it looks jerky since it is instantly hopping up .1.

I have tried timelines, but I am only able to go from 0-1 with one keypress. I just want the .1 increments. Thank you in advance.

If i understand you problem correctly, you can just use DoOnce node. [SPOILER]


You can still use a timeline but make the timeline’s curve drive a lerp float instead.
just before playing the timeline, you need to save a new variable (it’s just a copy of your main float variable). Then with the timeline, lerp from your new saved float to the same float +0.1, then the lerp sets your main float variable.

I have tried something like this, but since it moves incrementally like .1,.2,.3 and so on it seems “snappy” I am trying to have it move through all the minor increments like .10001, .10002, .10003 but very quickly. The red to blue should fade smoothly.

But… you also say that timeline doesnt do the job but it looks like it should.

And as you wrote:

That looks like you want that “snappy” behavior! )

So… actually you need something like this?:

  1. Press F once
  2. Color smooothly changes from red to something near red-blue and stop.
  3. Press F again
  4. Color continue changes from red+blue to almost blue
    and so on?

What I mean in regards to the timeline not working is it would run from 0-1 instead of giving me the increments.

To elaborate on the second part about the .1 increment, it wouldn’t go up instantly .1, but instead like .0001, .0002, .0003 etc all the way to .1.

Your step by step is correct, so the first press would go from .0001,.0002,.0003 all the way to .01 but very quickly. Then the next press would go from .0101, .0102, .0103 to .02. The third click would go from .02 to .0201, .0202, 0203 etc all the way to .03. Ideally, 10 key presses would take us from 0-1. Thanks again.

Here is a diagram, right now each box would represent a “snap” which is not what I am looking for.

I want the lerp to show the gradation between the boxes as well.

I dunno what you want )
That result?

Yes!!! Perfect!!! Thank you!

Yeah! Finally! :cool:

Current float = 0 by default
Timeline goes from 0 to 1.

Awesome, thanks again.

Check out this thread as well : How to make input axis lerp smoothly? - UE4 AnswerHub