噩梦 游戏结束 检测血量执行动画

来源:互联网 发布:我想买一个一心淘宝号 编辑:程序博客网 时间:2024/04/29 22:18
using UnityEngine;


namespace CompleteProject
{
    public class GameOverManager : MonoBehaviour
    {
        public PlayerHealth playerHealth;       // Reference to the player's health.




        Animator anim;                          // Reference to the animator component.




        void Awake ()
        {
            // Set up the reference.
            anim = GetComponent <Animator> ();
        }




        void Update ()
        {
            // If the player has run out of health...
            if(playerHealth.currentHealth <= 0)
            {
                // ... tell the animator the game is over.
                anim.SetTrigger ("GameOver");
            }
        }
    }
}
0 0