您的位置:首页 > 移动开发 > Unity3D

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

2015-07-28 18:34 471 查看
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");

            }

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  教程 unity3d