Connect PI and AC modules(連線玩家控制與角色控制模組)
阿新 • • 發佈:2018-12-13
Actor Controller
AC模組要和PI模組放在同一層下面
using System.Collections; using System.Collections.Generic; using UnityEngine; public class ActorController : MonoBehaviour { public GameObject model; public PlayerInput pi; [SerializeField]//把Animator暫時顯示到unity private Animator anim; // Use this for initialization void Awake () { //獲取元件 pi = GetComponent<PlayerInput>(); anim = model.GetComponent<Animator>();//吃一個模型 } // Update is called once per frame void Update () { anim.SetFloat("forward",pi.Dup);//把Dup的值餵給Animator裡面的forwad } }
玩家按鍵控制角色Get