アニメーションを連続再生すると位置が変わっていきリセットも効かない場合の対処方法; How to reset position and rotation before animation? Change clip settings!

f:id:peroon:20181122033205p:plain

前提

  • アニメーションの再生はPlayable APIを使用
  • アニメーション再生前に位置・回転をリセットしている
  • しかしアニメーションを連打すると地面にめり込んでいったりする
  • 「位置・回転のリセットが効かない!」という状況

アニメーション再生コード

    public void StartAnimation(int index)
    {
        if (graph.IsPlaying())
        {
            graph.Stop();
        }

        SetPosition(index);

        output.SetSourcePlayable(playableList[index]);
        playableList[index].SetTime(0);
        graph.Play();
    }

対処方法

  • Animation Clipを選んでEdit
  • 下記画像の赤丸の部分をONにしてApply
  • これでOK

f:id:peroon:20181122033346p:plain

Unityゲーム プログラミング・バイブル

Unityゲーム プログラミング・バイブル

  • 作者: 吉谷幹人,布留川英一,一條貴彰,西森丈俊,藤岡裕吾,室星亮太,車谷勇人,湊新平,土屋つかさ,黒河優介,中村優一,牙竜,コポコポ,かせ,hataken,monmoko,佐藤英一
  • 出版社/メーカー: ボーンデジタル
  • 発売日: 2018/05/01
  • メディア: 大型本
  • この商品を含むブログを見る