KillCharacter
游戏角色都可以杀死,所以将下列代码添加到Character类中
public virtual void KillCharacter()
{
Destroy(gameObject);
}
将hitPoints变量从Character类移动到Player类
新建Enemy脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Enemy : Character
{
// Start is called before the first frame update
float hitPoints;
}
修改Character
代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
public abstract class Character : MonoBehaviour
{
// Start is