LoginSignup
4
0

More than 3 years have passed since last update.

【Unity】Animation単体の時に、アニメーションを最初から再生する方法

Posted at

はじめに

Animatorを使わずに、Animationのみで実装する系の記事って意外と(?)無い気がするんですよね…。
というか、Unityのアニメーション関連は検索するのが難しい…。
で、「Animation 最初から」とかで検索かけてもあまりヒットしなくて毎回苦労しているのでメモ。

開発環境

Unity2019.1.8f1

巻き戻せば良いんや

再生する前に、最初の状態に戻しましょう。
「Animation 最初から」でググるからいけなかった。「巻き戻す」でググれば良かったんですね。

PlayAnime.cs
Animation anime;
anime = GameObject.Find("Animationがアタッチされているオブジェクト").GetComponent<Animation>();

anime.Rewind("アニメーション名");   //0フレーム目に巻き戻す
anime.Play("アニメーション名");

Animation-Rewind - Unity スクリプトリファレンス

最後に

他にもこんな方法あるよーというのがございましたらぜひご教示ください!

4
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
4
0