[Released] Low Pass Filter

I’d like to introduce my generic Low Pass Filter package. This is a very simple, easy to use, yet powerful tool for smoothing out continuous data. It helps with any kind of noises or instabilities, making for that nice, enjoyable feeling that everything works fluidly. Use it for filtering mouse or accelerometer input, adding a bit of inertia, smoothing out an object’s animation and thousands of different little things that are just too small to be perfected manually, but still count. It all works as below:

Usage is quite simple. Example:

using Vatio.Filters;
...
LowPassFilter<Vector3> filter = new LowPassFilter<Vector3>(0.05F, Vector3.zero);
...
Vector3 filteredValue = filter.Append(unfilteredValue);

The script works with both Unity free and Pro for all the target platforms. It is 100% written in C#, supplied as the heavily commented source code so it can be easily run anywhere there is Unity now and in the future, and it can easily be modified and extended to suit specific needs. There are three example scenes included - a desktop version, mobile version and a more interesting desktop game. Each of these scenes comes in 3 flavors, for C#, JS and Boo.

The script can be used with built-in variable types or any other type that supports arithmetic operations (in this case addition, multiplication and subtraction).

Supporting files:

  • The full instruction is available here.
  • A short example demonstrating script working is available here.
  • A more interesting game example sits right here.
  • And the Playmaker binding is here. It includes example scenes made with Playmaker.

If You have any questions, comments, or requests please write them here or e-mail them at unity3d@vatio.eu.

2 Likes

PLZ fix the link to the asset

Hi Summanuss, thanks for Your comment. I actually fixed this link about 15 minutes before Your comment. Thanks again!

Hello- I’ve been using the low pass function from this link http://wiki.unity3d.com/index.php/Low_Pass_Filter

I’m not getting the result I want from that low pass filter for Vector3’s- is your low pass filter similar to this one or can I expect much better results? Thank you.

Hi, thanks for the question!

Upon a quick read the principle seems the same - after all a low pass filter is a low pass filter.
Please post more details including what exactly is wrong with the results - perhaps we can solve this problem.

Thank you for the reply- I have an object in world space- a target- I’m getting that Vector3- applying the low pass filter then converting that to screen space so I can have a crosshair graphic track the target-

Without the low pass filter the crosshair movement is choppy- with the low pass filter its either very smooth but too slow to track the target- or fast enough to track the target but too choppy-

I understand Your problem, but I don’t think there are any magic solutions. If You can predict in any way the target’s movement You could use that to move the crosshair in the direction of the predicted position. Otherwise I’d suggest finding the best value for the filter factor - placing it in the middle between smooth and choppy should result in perhaps not a perfect solution, but a good one.

Today a new package has been uploaded - I changed directory structure to better follow Unity guidelines. Note however that everything is compatible with previous versions, and update should go without any problems.

Also I deleted all old packages - the new version will support only Unity 5.3.1 and above. Previous packages were obsolete and contained problems, which caused trouble for some users. The main script should actually be compatible with Unity 4.0+, but tested and officially supported versions are as mentioned 5.3.1+.

Hello,
I just purchased this asset and am planning on using it with PlayMaker. I downloaded the PM binding package, and I’m getting the following errors:
(…) does not contain a definition for ‘SetA’ and no accessible extension method ‘SetA’ accepting a first argument of type (…).
Coming in from all the localFilter.setA(a) lines.

Thanks for letting me know. Will fix and let you know ASAP.

Thanks for the quick response :slight_smile:

@Autarkis please redownload from http://vatio.eu/UnityAssetStore/LowPassFilter/LowPassFilterPlaymaker.unitypackage - let me know if everything’s fine now.

Works great! Thanks Vatio.