void CheckDistance() { bool inDistance = false; var dist = Vector3.Distance(Player.position, transform.position); inDistance = (dist < 51f); switch (inDistance) { case true: //look first m_AgressiveState = AgressiveState.LOOK; m_PassiveState = PassiveState.LOOK; //then do direction stuff if (dist < 30) { Vector3 dir = Player.transform.position - transform.position; isVisable = DetectPlayer(dir); } break; case false: m_AgressiveState = AgressiveState.IDLE; m_PassiveState = PassiveState.WANDER; isVisable = false; break; } }
void MoveToPlayer(bool det) { if (det) { m_AgressiveState = AgressiveState.ATTACK; m_PassiveState = PassiveState.INTERACT; } }
void Awake() { chaseState = new ChaseState(this); alertState = new AlertState(this); roamState = new RoamState(this); neutralState = new NeutralState(this); passiveState = new PassiveState(this); m_Nav = GetComponent <NavMeshAgent>(); }
protected override void BuildFSM() { PassiveState passive = new PassiveState(activateRaidus); passive.AddTransitionState(FSMStateID.Chase, FSMTransitions.Awoken); passive.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); IdleState idle = new IdleState(); idle.AddTransitionState(FSMStateID.Chase, FSMTransitions.SawPlayer); idle.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); ChaseState chase = new ChaseState(navAgent, agroDistance); chase.AddTransitionState(FSMStateID.Idle, FSMTransitions.PlayerOutOfRange); chase.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); DeadState dead = new DeadState(); AddFSMState(passive); AddFSMState(idle); AddFSMState(chase); AddFSMState(dead); }