思路:
先获取角色前面的敌人
通过攻击类别攻击敌人
新建脚本Player Attack,编辑脚本
public class PlayerAttack : MonoBehaviour {
public enum AttackRange
{
Forward,
Around
}
public static PlayerAttack _instance;
public Animator Anim;
public float forward_dis = 4f; //向前攻击的距离
public float around_dis = 4f; //周围攻击的距离
void Awake()
{
_instance = this;
}
void Update () {
}
//通过攻击类型释放攻击
public void OnAttack_SkillBtn(bool isPress, AttackType attackType)
{
ArrayList array = null;
if (PlayerControl._instance.animatorInfo.normalizedTime > 0.5f)
{
switch (attackType)
{
case AttackType.Basic:
array = GetEnemyInAttackRange(AttackRange.Forward);
foreach (GameObject go in array)
go.SendMessage("Hur