public virtual void FaceTo(Vector3 position) { actorObj.FaceTo(position); }
public behaviac.EBTStatus FollowPlayer() { //宝宝这个地方要修改 Vector3 vNavPos = CoreEntry.gActorMgr.MainPlayer.transform.position; Vector3 vDir = CoreEntry.gActorMgr.MainPlayer.transform.forward; vDir = -vDir; Vector3 vTmp1 = m_transform.position; vTmp1.y = 0; Vector3 vTmp2 = vNavPos; vTmp2.y = 0; float distance = Vector3.Distance(vTmp1, vTmp2); //是否需要区分BOSS战和普通小怪 if ((m_actor.curActorState == ACTOR_STATE.AS_ATTACK || m_AttackObj != null) && distance < 8f) { return(behaviac.EBTStatus.BT_SUCCESS); } else { if (distance < 4.5f) { return(behaviac.EBTStatus.BT_SUCCESS); } } //重新计算寻路位置 Quaternion qRoate = Quaternion.AngleAxis(30, Vector3.up); // - aiInfo.nAngle Vector3 vNewDir = qRoate * vDir * 3.0f; vNewDir = vNewDir + vNavPos; vNavPos = vNewDir; //增加个判断,如果跟班和主角距离太远,则直接拉 float fDistance = Vector3.Distance(m_transform.position, CoreEntry.gActorMgr.MainPlayer.transform.position); if (fDistance > 20 && m_actor.curActorState != ACTOR_STATE.AS_ATTACK) { m_transform.position = vNavPos; } if (distance < 2f) { StateParameter param = new StateParameter(); param.state = ACTOR_STATE.AS_STAND; m_actor.RequestChangeState(param); return(behaviac.EBTStatus.BT_SUCCESS); } //目标没改变,且run状态,不处理 if (m_movePos.Equals(vNavPos) && m_actor.curActorState == ACTOR_STATE.AS_RUN) { return(behaviac.EBTStatus.BT_RUNNING); } if (m_movePos.Equals(vNavPos) && m_actor.curActorState == ACTOR_STATE.AS_STAND && distance < 0.1f) { return(behaviac.EBTStatus.BT_SUCCESS); } m_actor.FaceTo(vNavPos); if (m_actorObject.MoveToPos(vNavPos)) { m_movePos = vNavPos; } return(behaviac.EBTStatus.BT_RUNNING); }