using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PatrolState:FSMState {
public PatrolState(Transform[] ts)
{
state = State.Patrol;
wayPonts = ts;
turnSpeed = 6;
moveSpeed = 280;
FindNextPoint();
}
public override void Reason(Transform player, Transform aiObj)
{
if (Vector3.Distance(player.position, aiObj.position) < chaseDistance)
{
aiObj.GetComponent<FSMManager>().StateTransition(Transition.SeePlayer);
}
}
public override void Action(Transform player, Transform aiObj)
{
if (Vector3.Distance(target, aiObj.position) < arriveDistance)
{
FindNextPoint();
}
Quaternion rotation = Quaternion.LookRotation(target - aiObj.position);
aiObj.rotation = Quaternion.Slerp(aiObj.rotation, rotation, Time.deltaTime * turnSpeed);
CharacterController cc = aiObj.GetComponent<CharacterController>();
cc.SimpleMove(aiObj.forward * Time.deltaTime * moveSpeed);
AnimationManagerEnemy animation = aiObj.GetComponent<AnimationManagerEnemy>();
animation.curState = animationState.Move;
}
}
PatrolState
最新推荐文章于 2019-03-11 23:20:04 发布