Skip to content

Instantly share code, notes, and snippets.

@PopupAsylumUK
Created May 23, 2017 13:01
Show Gist options
  • Save PopupAsylumUK/524f97a1f8b5ca42b2d7114c2d4a24d2 to your computer and use it in GitHub Desktop.
Save PopupAsylumUK/524f97a1f8b5ca42b2d7114c2d4a24d2 to your computer and use it in GitHub Desktop.
A Smooth Clipping Function
public static float SmoothClip(float input, float min, float max, float spread, float step) {
float timelinePosition = (input - min) / (max - min) * (1 - spread) + spread;
float signedDistanceToScrubber = timelinePosition - step;
float normalizedDistanceToScrubber = signedDistanceToScrubber / spread;
return Mathf.Clamp01(1 - normalizedDistanceToScrubber);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment