Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

What is the best way to smooth a float value over time?

Hi Folks... this may seem like a weirdly simple question and I'm kind of embarrassed to ask. But I haven't seen it anywhere: what is the best (smoothest, controllable, performant) way to smooth constant incoming values (float, vector, rotator, etc) in Blueprints?

Like for instance, something like smoothing a mouse float input.

Product Version: Not Selected
more ▼

asked Jan 15 '19 at 01:22 AM in Blueprint Scripting

avatar image

1k 8 17 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Try implementing a moving average:

  1. You create a list L of length N, this is where the last N values are stored.

  2. You keep track the current number of valid values in L using variable LVC.

  3. You also store the sum of all values stored in L using a variable LS.

  4. When a new value comes in you put it a the end of L. If L is full then you throw away the oldest value, shift the rest and set then new value as last.

  5. Then you update the LS by subtracting the thrown away value and adding the new value.

  6. And finally you can calculate the rolling average: LS / LVC.

By playing with N you can fine tune how "twitchy" the output is.

more ▼

answered Jan 15 '19 at 06:58 AM

avatar image

1.6k 80 94 146

avatar image ThompsonN13 Jan 16 '19 at 01:29 AM

i believe your talking something akin to the following picture. i was thinking a similar idea but i initially though about changing the sample rate rather than the number of samples but it still accomplishes the same thing.

oh and my example may not be perfectly optimized fyi.

alt text

or depending on the data being processed and how it needs to be used you could just divide, round, multiply, which will give you an approximated value but wont account well for large spikes in the value.

alt text

capture.png (335.1 kB)
capture1.png (71.9 kB)
avatar image aNorthStar Jan 23 '19 at 05:13 AM

@ZoltanE & @ThompsonN13 ... makes perfect sense, thank you both! :)

I guess I was kind of hoping that something inbuilt... most likely InterpTo... to smooth such a stream of values (float, rotator, vector, etc)?

avatar image Jacky Jan 23 '19 at 12:13 PM

There is Interp To for each variable type; FInterp To, VInterp To, etc.


avatar image aNorthStar Jan 24 '19 at 12:13 AM

thanks @Jacky... I know... what I was wondering was if there was a way to use this node (or another interpolation node) to smooth a stream of values over time?

avatar image Narghile Jan 24 '19 at 12:50 AM

Could you use a Timeline with a curve float?

avatar image aNorthStar Jan 24 '19 at 12:57 AM

@Narghile... this also did kind of occur to me, but I'm not sure how it would work with a value ...to be smoothed out.. coming in on each frame. I can understand how a timeline would work to blend from one set of values (say 0 = mouse input float strength) to another (1 = full mouse input float strength).

But I'm not sure how a timeline would smooth out a stream of mouse input float values... I'm open to suggestion though:)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question