今回は、UnityでAnimationを動かすさい自身がAnimationがループせず1度実行しただけで止まってしまう場合の対処法を解説します。
Animationがループしない原因
ほとんどの場合、AnimationのLoop Time(ループタイム)にチェックが入っておらず、ループしない場合が多いです。
Hierarchy→AnimationがループしないキャラクターのGameObjectを選択してください。
PlayerControllerをダブルクリックしてAnimator Windowを開きます。
原因のTransitionを選択します。
今回は、歩いている最中にキャラクターのAnimationがループせずに止まってしまうので、arthur_walk_01を選択します。
arthur_wall_01のInspectorでLoop Timeにチェックマークが入っているか確認します。
入っていなければチェックを入れてください
チェックを入れたら必ずしたのApplyをクリックしてください。
クリックしないと更新されません。
これで、AnimationがLoopするようになりました。
歩く、走るなどの同じ動作を繰り返すときには必ず必要です。
今回使用したAnimationのスクリプト
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerManager : MonoBehaviour { Rigidbody rb; Animator animator; float x; float z; // Start is called before the first frame update void Start() { rb = GetComponent<Rigidbody>(); animator = GetComponent<Animator>(); } // Update is called once per frame void Update() { x = Input.GetAxisRaw("Horizontal"); z = Input.GetAxisRaw("Vertical");
|
コメント