Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Stals · May 30, 2015 at 05:19 PM · curvecurveseasing

Easing .curves

Is there any custom "*.curves" that are close to this? http://www.inkfood.com/wordprez/wp-content/uploads/easingFunctions.png With bounce, elastic, ect?

Unity allows to save them to your project, I don't know why i couldn't google any. I'm currently using Unity 4.6 (don't know maybe it changed in Unity 5) I can't belive there is none that everybody uses.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Stals · May 23, 2016 at 03:25 PM

Forgot to update the question when I got the answer from the different source

Thanks to the user @ntakushima on Twitter for linking this pre-generated AnimationCurve presets from Penner's easing functions. They are very useful for example for NGUI tweening or other standalone tweening libraries where you specify a tween in an Inspector. So here it is - Github: EasingCurvePresets

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ABerlemont · May 23, 2016 at 03:30 PM 0
Share

Cool. Thanks for sharing.

avatar image
0

Answer by ABerlemont · May 23, 2016 at 02:38 PM

Check the plugin "iTween" on the asset store you can get all standard curves

 using UnityEngine;
 
 public class EasingCurves {
 
   #region Easing Curves
 
   public float linear(float start, float end, float value)
   {
     return Mathf.Lerp(start, end, value);
   }
 
   public float clerp(float start, float end, float value)
   {
     float min = 0.0f;
     float max = 360.0f;
     float half = Mathf.Abs((max - min) * 0.5f);
     float retval = 0.0f;
     float diff = 0.0f;
     if ((end - start) < -half)
     {
       diff = ((max - start) + end) * value;
       retval = start + diff;
     }
     else if ((end - start) > half)
     {
       diff = -((max - end) + start) * value;
       retval = start + diff;
     }
     else retval = start + (end - start) * value;
     return retval;
   }
 
   public float spring(float start, float end, float value)
   {
     value = Mathf.Clamp01(value);
     value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value)));
     return start + (end - start) * value;
   }
 
   public float easeInQuad(float start, float end, float value)
   {
     end -= start;
     return end * value * value + start;
   }
 
   public float easeOutQuad(float start, float end, float value)
   {
     end -= start;
     return -end * value * (value - 2) + start;
   }
 
   public float easeInOutQuad(float start, float end, float value)
   {
     value /= .5f;
     end -= start;
     if (value < 1) return end * 0.5f * value * value + start;
     value--;
     return -end * 0.5f * (value * (value - 2) - 1) + start;
   }
 
   public float easeInCubic(float start, float end, float value)
   {
     end -= start;
     return end * value * value * value + start;
   }
 
   public float easeOutCubic(float start, float end, float value)
   {
     value--;
     end -= start;
     return end * (value * value * value + 1) + start;
   }
 
   public float easeInOutCubic(float start, float end, float value)
   {
     value /= .5f;
     end -= start;
     if (value < 1) return end * 0.5f * value * value * value + start;
     value -= 2;
     return end * 0.5f * (value * value * value + 2) + start;
   }
 
   public float easeInQuart(float start, float end, float value)
   {
     end -= start;
     return end * value * value * value * value + start;
   }
 
   public float easeOutQuart(float start, float end, float value)
   {
     value--;
     end -= start;
     return -end * (value * value * value * value - 1) + start;
   }
 
   public float easeInOutQuart(float start, float end, float value)
   {
     value /= .5f;
     end -= start;
     if (value < 1) return end * 0.5f * value * value * value * value + start;
     value -= 2;
     return -end * 0.5f * (value * value * value * value - 2) + start;
   }
 
   public float easeInQuint(float start, float end, float value)
   {
     end -= start;
     return end * value * value * value * value * value + start;
   }
 
   public float easeOutQuint(float start, float end, float value)
   {
     value--;
     end -= start;
     return end * (value * value * value * value * value + 1) + start;
   }
 
   public float easeInOutQuint(float start, float end, float value)
   {
     value /= .5f;
     end -= start;
     if (value < 1) return end * 0.5f * value * value * value * value * value + start;
     value -= 2;
     return end * 0.5f * (value * value * value * value * value + 2) + start;
   }
 
   public float easeInSine(float start, float end, float value)
   {
     end -= start;
     return -end * Mathf.Cos(value * (Mathf.PI * 0.5f)) + end + start;
   }
 
   public float easeOutSine(float start, float end, float value)
   {
     end -= start;
     return end * Mathf.Sin(value * (Mathf.PI * 0.5f)) + start;
   }
 
   public float easeInOutSine(float start, float end, float value)
   {
     end -= start;
     return -end * 0.5f * (Mathf.Cos(Mathf.PI * value) - 1) + start;
   }
 
   public float easeInExpo(float start, float end, float value)
   {
     end -= start;
     return end * Mathf.Pow(2, 10 * (value - 1)) + start;
   }
 
   public float easeOutExpo(float start, float end, float value)
   {
     end -= start;
     return end * (-Mathf.Pow(2, -10 * value) + 1) + start;
   }
 
   public float easeInOutExpo(float start, float end, float value)
   {
     value /= .5f;
     end -= start;
     if (value < 1) return end * 0.5f * Mathf.Pow(2, 10 * (value - 1)) + start;
     value--;
     return end * 0.5f * (-Mathf.Pow(2, -10 * value) + 2) + start;
   }
 
   public float easeInCirc(float start, float end, float value)
   {
     end -= start;
     return -end * (Mathf.Sqrt(1 - value * value) - 1) + start;
   }
 
   public float easeOutCirc(float start, float end, float value)
   {
     value--;
     end -= start;
     return end * Mathf.Sqrt(1 - value * value) + start;
   }
 
   public float easeInOutCirc(float start, float end, float value)
   {
     value /= .5f;
     end -= start;
     if (value < 1) return -end * 0.5f * (Mathf.Sqrt(1 - value * value) - 1) + start;
     value -= 2;
     return end * 0.5f * (Mathf.Sqrt(1 - value * value) + 1) + start;
   }
 
   /* GFX47 MOD START */
   public float easeInBounce(float start, float end, float value)
   {
     end -= start;
     float d = 1f;
     return end - easeOutBounce(0, end, d - value) + start;
   }
   /* GFX47 MOD END */
 
   /* GFX47 MOD START */
   //public float bounce(float start, float end, float value){
   public float easeOutBounce(float start, float end, float value)
   {
     value /= 1f;
     end -= start;
     if (value < (1 / 2.75f))
     {
       return end * (7.5625f * value * value) + start;
     }
     else if (value < (2 / 2.75f))
     {
       value -= (1.5f / 2.75f);
       return end * (7.5625f * (value) * value + .75f) + start;
     }
     else if (value < (2.5 / 2.75))
     {
       value -= (2.25f / 2.75f);
       return end * (7.5625f * (value) * value + .9375f) + start;
     }
     else
     {
       value -= (2.625f / 2.75f);
       return end * (7.5625f * (value) * value + .984375f) + start;
     }
   }
   /* GFX47 MOD END */
 
   /* GFX47 MOD START */
   public float easeInOutBounce(float start, float end, float value)
   {
     end -= start;
     float d = 1f;
     if (value < d * 0.5f) return easeInBounce(0, end, value * 2) * 0.5f + start;
     else return easeOutBounce(0, end, value * 2 - d) * 0.5f + end * 0.5f + start;
   }
   /* GFX47 MOD END */
 
   public float easeInBack(float start, float end, float value)
   {
     end -= start;
     value /= 1;
     float s = 1.70158f;
     return end * (value) * value * ((s + 1) * value - s) + start;
   }
 
   public float easeOutBack(float start, float end, float value)
   {
     float s = 1.70158f;
     end -= start;
     value = (value) - 1;
     return end * ((value) * value * ((s + 1) * value + s) + 1) + start;
   }
 
   public float easeInOutBack(float start, float end, float value)
   {
     float s = 1.70158f;
     end -= start;
     value /= .5f;
     if ((value) < 1)
     {
       s *= (1.525f);
       return end * 0.5f * (value * value * (((s) + 1) * value - s)) + start;
     }
     value -= 2;
     s *= (1.525f);
     return end * 0.5f * ((value) * value * (((s) + 1) * value + s) + 2) + start;
   }
 
   public float punch(float amplitude, float value)
   {
     float s = 9;
     if (value == 0)
     {
       return 0;
     }
     else if (value == 1)
     {
       return 0;
     }
     float period = 1 * 0.3f;
     s = period / (2 * Mathf.PI) * Mathf.Asin(0);
     return (amplitude * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * 1 - s) * (2 * Mathf.PI) / period));
   }
 
   /* GFX47 MOD START */
   public float easeInElastic(float start, float end, float value)
   {
     end -= start;
 
     float d = 1f;
     float p = d * .3f;
     float s = 0;
     float a = 0;
 
     if (value == 0) return start;
 
     if ((value /= d) == 1) return start + end;
 
     if (a == 0f || a < Mathf.Abs(end))
     {
       a = end;
       s = p / 4;
     }
     else
     {
       s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
     }
 
     return -(a * Mathf.Pow(2, 10 * (value -= 1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start;
   }
   /* GFX47 MOD END */
 
   /* GFX47 MOD START */
   //public float elastic(float start, float end, float value){
   public float easeOutElastic(float start, float end, float value)
   {
     /* GFX47 MOD END */
     //Thank you to rafael.marteleto for fixing this as a port over from Pedro's UnityTween
     end -= start;
 
     float d = 1f;
     float p = d * .3f;
     float s = 0;
     float a = 0;
 
     if (value == 0) return start;
 
     if ((value /= d) == 1) return start + end;
 
     if (a == 0f || a < Mathf.Abs(end))
     {
       a = end;
       s = p * 0.25f;
     }
     else
     {
       s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
     }
 
     return (a * Mathf.Pow(2, -10 * value) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) + end + start);
   }
 
   /* GFX47 MOD START */
   public float easeInOutElastic(float start, float end, float value)
   {
     end -= start;
 
     float d = 1f;
     float p = d * .3f;
     float s = 0;
     float a = 0;
 
     if (value == 0) return start;
 
     if ((value /= d * 0.5f) == 2) return start + end;
 
     if (a == 0f || a < Mathf.Abs(end))
     {
       a = end;
       s = p / 4;
     }
     else
     {
       s = p / (2 * Mathf.PI) * Mathf.Asin(end / a);
     }
 
     if (value < 1) return -0.5f * (a * Mathf.Pow(2, 10 * (value -= 1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p)) + start;
     return a * Mathf.Pow(2, -10 * (value -= 1)) * Mathf.Sin((value * d - s) * (2 * Mathf.PI) / p) * 0.5f + end + start;
   }
   /* GFX47 MOD END */
 
   #endregion
 
 }
 
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Text along a curve 2 Answers

AnimationCurve, how can i know when the end of the curve has been reached? 3 Answers

how to use t variable in the bazier curve 2 Answers

Custom inspector curves similar to the 'Audio Source' volume/pan/spread Curves 0 Answers

How are AnimationCurves evaluated? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges