Skip to content
Download
API reference

InputModifierSmooth

Inherits: InputModifier < Resource < Shared < Object

Averages an input value over the last frames.

Gives the average of the value over the last sample_count frames. It smooths a jittery input (a noisy stick, uneven mouse motion) at the cost of some delay: the value takes that many frames to follow a change, and fades out over that many frames after the input stops, which can keep the action triggered a little longer.

The samples are kept for each mapping or action that uses the modifier, so one resource can be shared. The first time, every sample is filled with the current value; when sample_count changes, the samples start again.

TypeNameDefault
intsample_count4

int sample_count = 4

Setter/getter: set_sample_count(), get_sample_count()

How many frames are averaged. At least 1 (smaller values are raised to 1); 1 changes nothing.