c#
1コード 2using System.Collections; 3using System.Collections.Generic; 4using UnityEngine; 5using UnityEngine.AI; 6using UnityEngine.UI; 7public class zani : MonoBehaviour 8{ 9 // Start is called before the first frame update 10 public NavMeshAgent player; 11 public GameObject target; 12 public Animator anime; 13 int maxHp = 10; 14 int currentHp; 15 public Slider slider; 16 void Start() 17 { 18 player = gameObject.GetComponent<NavMeshAgent>(); 19 anime = GetComponent<Animator>(); 20 slider.value = 1; 21 currentHp = maxHp; 22 Debug.Log("Start currentHp : " + currentHp); 23 } 24 25 void Update() 26 { 27 anime.SetBool("walk", true); 28 { 29 anime.SetBool("attack", true); 30 } 31 else 32 { 33 anime.SetBool("attack", false); 34 } 35 if (target != null) 36 { 37 player.destination = target.transform.position; 38 } 39 } 40 private void OnTriggerEnter(Collider collider) 41 { 42 //Enemyタグのオブジェクトに触れると発動 43 if (collider.gameObject.tag == "Enemy") 44 { 45 //ダメージは1~100の中でランダムに決める。 46 int damage = Random.Range(1, 3); 47 Debug.Log("damage : " + damage); 48 49 //現在のHPからダメージを引く 50 currentHp = currentHp - damage; 51 Debug.Log("After currentHp : " + currentHp); 52 slider.value = (float)currentHp / (float)maxHp; ; 53 Debug.Log("slider.value : " + slider.value); 54 } 55 } 56} 57
にAnimator is not playing an AnimatorControllerと出てきて困ってます。アニメーションが動かない状態です。直し方わかりますか??
あなたの回答
tips
プレビュー