基本的には以下のリンクの記事を参照
Unity-Chan!を1時間ほどで「自在に動かす」使い方を公開してみた! - Unity不定期便
今回はunityちゃんではなく、自作モデルで行った。
下の画像のオレンジのところのチェックを外せばキーを押して即座にモーションが切り替わる
ジャンプのスクリプトは以下
アニメーションのstateのis_jump、変数名をjumpに設定している。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class jump : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
var motion = GetComponent<Animator>();
AnimatorStateInfo state = motion.GetCurrentAnimatorStateInfo(0);
if(Input.GetKeyDown(KeyCode.Space)){
motion.SetBool("jump", true);
}
if(state.IsName("is_jump")){
motion.SetBool("jump", false);
}
}
}
Humanoidを適用した3DモデルにLocomotion,Locomotion Playerを適用した後、ルートモーションを適用すれば、画面上を走り回らせることが出来る