🌊 Sin関数をちょっと便利に
Mathf.Sin
を使って5秒で一周する動きを作りたい場合には以下みたいな感じで書くのですが、たまに使うと正規化し忘れたりして値がなんか思ってたのと違うぞ?みたいな事になるのでメモ。
コピーしました
float duration = 5.0f;
float sin = Mathf.Sin((2 * Mathf.PI) * (1.0f / duration) * Time.time);
次使う時に楽なようにユーティリティクラスにしておきました。
コピーしました
public static class MathfUtil
{
static public float StretchSin(float duration)
{
return Mathf.Sin((2 * Mathf.PI) * (1.0f / duration) * Time.time);
}
}
Comment
comments powered by Disqus