LoginSignup
0
0

More than 3 years have passed since last update.

簡単イージング

Last updated at Posted at 2021-02-25

なぜかUnityにはイージングを制御する関数がありません。
なので自分用にイージングを極力簡略化したスクリプトを組みました。

本来イージングには開始値、終了値、経過時間、トータル時間の4つが必要ですが、実際イージングは比率しか求めないので開始位置と終了位置は無視して経過時間/トータル時間のみを渡して計算してます。

このスクリプトは0~1までの値を渡して、その値にイージング処理した値を返すものです。

たとえばLerpのt値にこれらの処理を加えることでイージング効果がでます。

Calc.cs
    public static float EasyEaseIn(float t)
    {
        return   t * t;
    }
    public static float EasyEaseOut(float t)
    {
        return -1 * t * (t - 2.0f);
    }
    public static float EasyEaseInOut(float t)
    {
        t = t *0.5f;
        if (t < 1) { return 0.5f * t * t; }
        t = t - 1;
        return -0.5f * (t * (t - 2.0f) - 1) ;
    }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0