Giter VIP home page Giter VIP logo

unity-easinganimationcurve's Introduction

Unity-EasingAnimationCurve

EasingAnimationCurve is a simple and fast solution of converting Easing functions to UnityEngine.AnimationCurve.

It used fewer keyframes to approximate the easing functions rather than sampling points averagely as keyframes.

There are only 2 ~ 9 keyframes in a curve.

  • You can download the curve presets if you only need the AnimationCurve resources.
  • Main features are all in EasingAnimationCurve.cs, and EasingAnimationCurveExample.cs shows all usages of this repo.

Preview

EaseInOutBounce: 9 keyframes EaseInExpo: 2 keyframes
EaseInOutCubic: 3 keyframes EaseInOutElastic: 9 keyframes

Show all comparaison of easing function(GREEN) and animation curve(RED):

AnimationCurve Presets

You can put the presets into your project without any scripts. See EasingFunctionPresets.unitypackage.

EaseElastic has an obvious error

Only Elastic series have larger errors with the original easing function. But it still works as elastic function with different spring arguments. So it works for me.

If you feel the error is too large, you can make precise points via CubicBezierFitter and replace the original bezier points in EasingAnimationCurve. You can open Example scene and get the usage of them from EasingAnimationCurveExample.cs.

Implementation

1. Easing Function -> Cubic Bezier

I used the data in this paper Easing Functions in the New Form Based on Bézier Curves by Dariusz Sawicki 2016 to convert them into cubic bezier.

And I found this thread with a solution to fitting cubic bezier by data points.

https://stackoverflow.com/questions/5525665/smoothing-a-hand-drawn-curve

It's very helpful to make other types of curve to Bezier curve by fitting. See CubicBezierFitter.cs

2. Cubic Bezier -> Animation Curve

See EasingAnimationCurve.cs: here

There are some helpful references:

Environment

Unity 2019.4.12f1 LTS

unity-easinganimationcurve's People

Contributors

qwe321qwe321qwe321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.