Skip to content

Fixed implementation of Unreal's "Weighted Moving Average Rotator" that properly understands angles.

Notifications You must be signed in to change notification settings

Rixx-io/weighted-moving-average-rotator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

weighted-moving-average-rotator

Fixed implementations of Unreal's "Weighted Moving Average Rotator" and "Dynamic Weighted Moving Average Rotator" blueprint functions that properly understand angles. See for example this forum post.

The fix

Unreal's implementation incorrectly treats the samples as simple linear points on a number line. When the Previous and Current Samples cross the circular boundary at -180 / 180, Unreal glitches. The fix is simple: correctly calculate the angular distance between the Samples. -179 to 179 is a distance of two, for example.

Add these source files to your C++ project's Source directory and look for the functions "Weighted Moving Average Rotator (Fixed)" and "Dynamic Weighted Moving Average Rotator (Fixed)" in your blueprint.

Example

This is from a project that updates an Actor with location and rotation data from an external controller. This external controller data is noisy, and needs to be stabilized to look good. The external controller component places the raw values into class variables named "Tracked Location" and "Tracked Rotation". On every tick I take those values, smooth them, and set the Actor's transform.

Example Usage

About

Fixed implementation of Unreal's "Weighted Moving Average Rotator" that properly understands angles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages