Animation機能を使うと、オブジェクトをほっといても動くようにすることができます。
今回はAnimationで単純に自動でアニメするオブジェクトを作り、その速度を変更するところまで作ります。
成果物

複数の画像を組み合わせてアニメを作り、画像が切り替わる速度を変更します。
Animationの作り方

いくつか画像を作っておいて、Shiftを押しながらまとめて選択し、シーンビューに放り込むと、

animなる拡張子のファイルを作る旨ウィンドウが出るので、OKを押します。

4つの画像が統合されたオブジェクトが作成され、Assetsにも何か色々増えます。とりあえずこの段階でゲームを実行すると、

勝手にアニメーションするオブジェクトが作られていることが確認できます。
画像が切り替わる速度の変更

Assetsにふたつアセットが追加されているはずですが、登録した画像の名前がついた四角形のほうをダブルクリックすると、

アニメータータブが開くので、New Animationをクリックします。

速度をデフォルトの1から任意の値に変更し、

アニメータータブはタブの上で右クリック→タブを閉じるで一度閉じます。

再度ゲームを実行すると、

自動アニメーションの速度が変更されていることが確認できます。

やりたいことから逆引きするUNITYの使い方まとめ
Unityをやりたいことから学習していけるよう、機能・用途別にまとめたページです。C#の命令別の逆引きは現時点で作っていません。2019の時期に書き始めているので、それより前のバージョンについては言及しません。
コメント