Smoothed State Follower
by HB_Stratos
uploaded 2023-02-21
stock+DLC ship

Smoothed State Follower

This is a system that takes a requested state (play position of the input KAL) and smoothly moves the output towards the requested input. Input can change at any time, and the output will follow correctly. It effectively emulates how traverse speed would affect a hinge, but it can be applied to an entire sequence of events in a KAL.
Note that currently the acceleration from zero to movement is instant, but there is a slow down when approaching the target.
Also note that the speed of the smoothed follower can be adjusted by changing the play duration of the output KAL.

How it works

This system uses my subtraction KAL setup for it’s main component. If you don’t know how it works, please read my write-up for it at The subtraction here takes the target as one input, while the other input is the position of the output.
This gives us a value of above 0.5 if the output is smaller than the input, and smaller than 0.5 if the output is bigger than the input.
We then take this value and map it so that if the output is lagging behind the input, we set it’s play speed to 100%, and to -100% if the output is ahead. Like that the output KAL will always move in the direction of the input KAL value until they are equal.


You may wonder how I get -100% play speed on a KAL. It’s pretty simple, and is even still in place on the example. You can create a curve inside the field for a servo, which allows +-180 as values, then copy and paste that curve into any other field, and it will work fine. KAL overclocking, but for curves inside a KAL.
KSP sometimes gets confused with the loop setup here, where a KAL is modifying another KAL, which is modifying yet another KAL, which then modifies the first KAL. One cannot manually enter numbers into the curve editor when a KAL is playing, and due to the loop setup KSP sometimes thinks a KAL is playing when it isn’t. This can be solved by ensuring no KAL is playing, then leaving to the space center and re-entering the hangar. Then it will work again until the wrong combination of sliders is moved again.
This setup could also be made to work with one less KAL by removing the KAL that mirrors the play position of the Output. However for readability of how it works (and thinking of that too late) I have left it in tact.
Fun Fact: The Output KAL has to be set to playing with the reverse pattern of ping-pong as it has to be able to move right up to the end of it’s movement, where normally the playback would be paused, breaking the system. Loop wouldn’t work as then the state could jump from one end to the other. Ping-pong works as the play dir is reversed when the play head collides with the end, but as we are using -100% playback speed to move backwards it simply collides twice and is then moving in forwards direction with a speed of -100%, aka backwards, without the KAL being set to backwards.
A stock aircraft called Smoothed State Follower. Built with 13 of the finest parts, its root part is structuralPanel2.

Built in the SPH in KSP version 1.12.3.


  • Type: SPH
  • Class: ship
  • Part Count: 13
  • Pure Stock
  • KSP: 1.12.3

swipe to switch images, tap to close