3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Unity Animation CurveのConstantカーブを設定したい

Last updated at Posted at 2021-09-27

初めに

Unity Animation Curveでアニメーションをスクリプトで登録する

Keyframe(0, 1.0f);

こんな感じで、ただ、デフォルトだと下記のようなLinearかSmoothみたいになってしまう。

image.png

値をConstantで設定したい

今回は下記のようにパキっとしたい!
青で囲ったみたいなな
image.png

検索すると出てくる。。

Unity questionsで 解決

ここにかいてあるのは、Keyframeの第3,4引数のinTangentとoutTangentにinfinityを設定すれば良いと書いてある

スクリプトを下記のようにする

Keyframeの第3,4引数の値を

Keyframe(0, 1.0f, float.PositiveInfinity, float.PositiveInfinity)

floatのInfinityであるMathfで宣言されているInfinityは同じ値を指しているので、どちらでもいいです。
float.PositiveInfinity
Mathf.Infinity

スクリプトでKeyframeしていするとConstantのチェックボックスにはなってはいないが
値はConstantを同じになります。
image.png

最後に

今回もgoogle先生に聞くだけで解決されたのは、嬉しい!
実装がある程度経っているのは、調べると出てくるはいいですね~!!

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?