private void MakeFSM() { PatrolState patrol = new PatrolState(player, transform, path); patrol.AddTransition(Transition.GuardPlayer, StateID.GuardID); GuardState guard = new GuardState(player, transform); guard.AddTransition(Transition.AutoPatrol, StateID.PatrolID); guard.AddTransition(Transition.ChasingPlayer, StateID.ChasingID); ChaseState chase = new ChaseState(player, transform); chase.AddTransition(Transition.GuardPlayer, StateID.GuardID); chase.AddTransition(Transition.AttackPlayer, StateID.AttackID); AttackState attack = new AttackState(player, transform); attack.AddTransition(Transition.GuardPlayer, StateID.GuardID); attack.AddTransition(Transition.ChasingPlayer, StateID.ChasingID); fsm = new FSMSystem(); fsm.AddState(patrol); fsm.AddState(guard); fsm.AddState(chase); fsm.AddState(attack); }
// Use this for initialization void Awake() { attackState = new AttackState(this); chaseState = new ChaseState(this); evadeState = new EvadeState(this); orbitState = new OrbitState(this); }
private void ConstructFSM() { //Get the list of points pointList = GameObject.FindGameObjectsWithTag("WanderPoint"); Transform[] waypoints = new Transform[pointList.Length]; int i = 0; foreach (GameObject obj in pointList) { waypoints[i] = obj.transform; i++; } //Add Transition and State Pairs PatrolState patrol = new PatrolState(waypoints, this); //If the tank sees the player while patrolling, move to chasing state patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); //If the tank loses health while patrolling, move to dead state patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead); patrol.AddTransition(Transition.HalfHealth, FSMStateID.Rage); ChaseState chase = new ChaseState(waypoints, this); //If the tank loses the player while chasing, move to patrol state chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); //If the tank reaches the player while attacking, move to attack state chase.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking); //If the tank loses health while patrolling, move to dead state chase.AddTransition(Transition.NoHealth, FSMStateID.Dead); chase.AddTransition(Transition.HalfHealth, FSMStateID.Rage); AttackState attack = new AttackState(waypoints, this); //If the tank loses the player while attacking, move to patrol state attack.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); //If the player is within sight while attacking, move to chase state attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); //If the tank loses health while attacking, move to dead state attack.AddTransition(Transition.NoHealth, FSMStateID.Dead); attack.AddTransition(Transition.HalfHealth, FSMStateID.Rage); DeadState dead = new DeadState(this); //When there is no health, go to dead state dead.AddTransition(Transition.NoHealth, FSMStateID.Dead); RageState rage = new RageState(this); rage.AddTransition(Transition.NoHealth, FSMStateID.Dead); rage.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); //Add states to the state list AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); AddFSMState(rage); }
private void ConstructFSM() { //Get the list of points //pointList = GameObject.FindGameObjectsWithTag("PatrolPoint"); //Transform[] waypoints = new Transform[pointList.Length]; //int i = 0; //foreach(GameObject obj in pointList) //{ // waypoints[i] = obj.transform; // i++; //} int pointlength = Random.Range(3, 5); Debug.Log("pointlength = " + pointlength); Transform[] waypoints = new Transform[pointlength]; float maxdistance = 50; float mindistance = -30; GameObject partpointparent = new GameObject(); partpointparent.transform.position = role.transform.position; partpointparent.name = role.name + "[partolpoints]"; for (int i = 0; i < pointlength; i++) { Vector3 pos = new Vector3(role.transform.position.x + CreatPatrolRange(maxdistance, mindistance), 0, role.transform.position.z + CreatPatrolRange(maxdistance, mindistance)); GameObject go = new GameObject(); go.transform.position = pos; go.transform.parent = partpointparent.transform;; waypoints[i] = go.transform; } Debug.Log("waypoints length -> " + waypoints.Length); PatrolState patrol = new PatrolState(waypoints); patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead); ChaseState chase = new ChaseState(waypoints); chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); chase.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking); chase.AddTransition(Transition.NoHealth, FSMStateID.Dead); AttackState attack = new AttackState(waypoints); attack.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); attack.AddTransition(Transition.NoHealth, FSMStateID.Dead); DeadState dead = new DeadState(); dead.AddTransition(Transition.NoHealth, FSMStateID.Dead); AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); }
private void Awake() { searchState = new SearchState(this); chaseState = new ChaseState(this); patrolState = new PatrolState(this); navMeshAgent = GetComponent <NavMeshAgent>(); }
void Awake () { patrolState = new PatrolState(this); alertState = new AlertState(this); chaseState = new ChaseState(this); navMeshAgent = GetComponent<NavMeshAgent>(); }
private void ConstructFSM() { pointList = GameObject.FindGameObjectsWithTag("DestinationPoint"); Transform[] wayPoints = new Transform[pointList.Length]; int i = 0; foreach (GameObject obj in pointList) { wayPoints[i] = obj.transform; i++; } PatrolState patrol = new PatrolState(wayPoints); patrol.AddTransition(Transition.FoundPlayer, FSMStateID.Chasing); ChaseState chase = new ChaseState(wayPoints); chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); chase.AddTransition(Transition.ReachedPlayer, FSMStateID.Attacking); AddFSMState(patrol); AddFSMState(chase); }
private void ConstructFSM() { FSMState patrol = new PatrolState(this); patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); patrol.AddTransition(Transition.ReachedPlayer, FSMStateID.Attacking); AddFSMState(patrol); FSMState chase = new ChaseState(); chase.AddTransition(Transition.LostPlayer, FSMStateID.Searching); chase.AddTransition(Transition.ReachedPlayer, FSMStateID.Attacking); AddFSMState(chase); FSMState search = new SearchState(this); search.AddTransition(Transition.GiveUpSearching, FSMStateID.Patrolling); search.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); AddFSMState(search); FSMState attack = new AttackState(this); attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); attack.AddTransition(Transition.LostPlayer, FSMStateID.Searching); AddFSMState(attack); }
public void Hide() { if (hideAndSeekRole == ItState.Hider) { hideAndSeekState = ChaseState.Hidden; } }
protected AI(string name, Texture tex, int width, int height, int tilesPerRow, int[] keyFrames, float frameLength, bool show, bool stop) : base(name) { Renderer = new AnimationRenderer(tex, width, height, tilesPerRow, keyFrames, frameLength, show, stop); Renderer.RenderOffset = (int)RenderLayer.AI; AddComponent(Renderer); this.Layer = (uint)CollisionLayer.Enemy; patrolState = new PatrolState(this); chaseState = new ChaseState(this); patrolState.Next = chaseState; chaseState.Next = patrolState; BoxCollider2D collider = new BoxCollider2D(new Vector2(1, 1)); collider.CollisionEnter += OnCollisionEnter; AddComponent(collider); Rigidbody2D rigidBody = new Rigidbody2D(); rigidBody.IsGravityAffected = false; AddComponent(rigidBody); AddComponent(new BoxCollider2DRenderer(new Vector4(1f, 0f, 0f, 0f))); patrolState.OnStateEnter(); AddComponent(new FSMUpdater(patrolState)); }
virtual protected void InitState() { State idleState = new IdleState(); idleState.Init(this); _stateDictionary.Add(eState.IDLE, idleState); State moveState = new MoveState(); moveState.Init(this); _stateDictionary.Add(eState.MOVE, moveState); State attackState = new AttackState(); attackState.Init(this); _stateDictionary.Add(eState.ATTACK, attackState); State chaseState = new ChaseState(); chaseState.Init(this); _stateDictionary.Add(eState.CHASE, chaseState); State patrolState = new PatrolState(); patrolState.Init(this); _stateDictionary.Add(eState.PATROL, patrolState); }
private void ConstructFSM() //初始化拥有哪些状态,并为拥有的状态设置转化和状态ID { PatrolState tPatrolState = new PatrolState(wayPoints); tPatrolState.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); tPatrolState.AddTransition(Transition.NoHealth, FSMStateID.Dead); ChaseState tChaseState = new ChaseState(wayPoints); tChaseState.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking); tChaseState.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); tChaseState.AddTransition(Transition.NoHealth, FSMStateID.Dead); AttackState tAttackState = new AttackState(wayPoints); tAttackState.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); tAttackState.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); tAttackState.AddTransition(Transition.NoHealth, FSMStateID.Dead); DeadState tDeadState = new DeadState(); tDeadState.AddTransition(Transition.NoHealth, FSMStateID.Dead); AddFSMState(tPatrolState); AddFSMState(tPatrolState); AddFSMState(tPatrolState); AddFSMState(tPatrolState); Events.AddEvent(EventSign.GAME_START, DestroySelf, this); Events.Send(EventSign.GAME_START, new EventArg("123")); }
private void GiveUpChase() { BoardingManager.EndBoardingAction(); ChaseState chase = _controller.ChangeToState <ChaseState>(); chase.target = _target; }
private void Awake()//Before Start, initializes states and gets component reference for NavMeshAgent attached to enemy { chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); }
void CreateAI() { chaseState = new ChaseState(this.gameObject); attackState = new AttackState(this.gameObject); currentState = AI_STATE.CHASE_STATE; }
protected override void BuildFSM() { PatrolState patrol = new PatrolState(PatrolPoints, navAgent, agroDistance); patrol.AddTransitionState(FSMStateID.Shoot, FSMTransitions.SawPlayer); patrol.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); ShootState shoot = new ShootState(chargeDistance, spawnerScript); shoot.AddTransitionState(FSMStateID.Patrol, FSMTransitions.PlayerOutOfRange); shoot.AddTransitionState(FSMStateID.Chase, FSMTransitions.PlayerTooClose); shoot.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); ChaseState chase = new ChaseState(navAgent, chargeDistance); chase.AddTransitionState(FSMStateID.Shoot, FSMTransitions.PlayerOutOfRange); chase.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); DeadState dead = new DeadState(); AddFSMState(patrol); AddFSMState(shoot); AddFSMState(chase); AddFSMState(dead); }
void MakeFSM() { PatrolState patrol = new PatrolState(); ChaseState chase = new ChaseState(); AttackState attack = new AttackState(); DeadState dead = new DeadState(); IdleState idle = new IdleState(); MoveState move = new MoveState(); patrol.AddTransition(Transition.SawEnemy, chase); patrol.AddTransition(Transition.NoHP, dead); chase.AddTransition(Transition.LostEnemy, patrol); chase.AddTransition(Transition.ReachEnemy, attack); chase.AddTransition(Transition.NoHP, dead); attack.AddTransition(Transition.LostEnemy, patrol); attack.AddTransition(Transition.SawEnemy, chase); attack.AddTransition(Transition.NoHP, dead); AddState(StateID.Patrol, patrol); AddState(StateID.Chase, chase); AddState(StateID.Attack, attack); AddState(StateID.Dead, dead); m_stateMachine.Start(patrol); }
public void Chase(GameObject hider) { // Play the spotted animation currentState = ChaseState.Chase; searchedList.Clear(); ChangeMoveTarget(hider.transform, hider.GetComponent <PlayerController>().bounds);; }
private void Awake() { chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); wanderState = new WanderState(this); }
//Construct the Finite State Machine for the AI Car behavior private void ConstructFSM() { //Get the list of points pointList = GameObject.FindGameObjectsWithTag("WandarPoints"); Transform[] waypoints = new Transform[pointList.Length]; int i = 0; foreach (GameObject obj in pointList) { waypoints[i] = obj.transform; i++; } PatrolState patrol = new PatrolState(waypoints); patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead); ChaseState chase = new ChaseState(waypoints); chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); chase.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking); chase.AddTransition(Transition.NoHealth, FSMStateID.Dead); AttackState attack = new AttackState(waypoints); attack.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); attack.AddTransition(Transition.NoHealth, FSMStateID.Dead); DeadState dead = new DeadState(); dead.AddTransition(Transition.NoHealth, FSMStateID.Dead); AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); }
private void ConstructFSM() { //Get the list of points pointList = GameObject.FindGameObjectsWithTag("WandarPoint"); Transform[] waypoints = new Transform[pointList.Length]; int i = 0; foreach (GameObject obj in pointList) { waypoints[i] = obj.transform; i++; } PatrolState patrol = new PatrolState(waypoints, this); patrol.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); patrol.AddTransition(Transition.LowHealth, FSMStateID.Healing); patrol.AddTransition(Transition.NoHealth, FSMStateID.Dead); patrol.AddTransition(Transition.HasBoredom, FSMStateID.Bored); ChaseState chase = new ChaseState(waypoints, this); chase.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); chase.AddTransition(Transition.ReachPlayer, FSMStateID.Attacking); chase.AddTransition(Transition.LowHealth, FSMStateID.Healing); chase.AddTransition(Transition.NoHealth, FSMStateID.Dead); AttackState attack = new AttackState(waypoints, this); attack.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); attack.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); attack.AddTransition(Transition.LowHealth, FSMStateID.Healing); attack.AddTransition(Transition.NoHealth, FSMStateID.Dead); DeadState dead = new DeadState(); dead.AddTransition(Transition.NoHealth, FSMStateID.Dead); HealState heal = new HealState(waypoints, this); heal.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); heal.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); heal.AddTransition(Transition.NoHealth, FSMStateID.Dead); BoredState bored = new BoredState(waypoints, this); bored.AddTransition(Transition.SawPlayer, FSMStateID.Chasing); bored.AddTransition(Transition.LostPlayer, FSMStateID.Patrolling); bored.AddTransition(Transition.LowHealth, FSMStateID.Healing); bored.AddTransition(Transition.NoHealth, FSMStateID.Dead); AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); AddFSMState(heal); AddFSMState(bored); }
private void Awake() { chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); aim = GetComponent<Aim>(); autoFire = GetComponent<AutoFire>(); }
private void Awake() { patrolState = new PatrolState(this); alertState = new AlertState(this); chaseState = new ChaseState(this); trackingState = new TrackingState(this); navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); }
void Awake() { m_ChaseState = new ChaseState(this); m_AlertState = new AlertState(this); m_PatrolState = new PatrolState(this); m_NavMeshAgent = GetComponent <NavMeshAgent>(); }
void Awake () { wanderState = new WanderState (wanderTimeMin, wanderTimeMax, wanderSpeed, wanderRadius); idleState = new IdleState (idleTime); chaseState = new ChaseState (chaseTime, chaseSpeed); attackState = new AttackState (); deadState = new DeadState (); leaveAltarState = new LeaveAltarState (); }
void Awake() { attackState = new AttackState(this); chaseState = new ChaseState(this); idleState = new IdleState(this); patrolState = new PatrolState(this); playerBuddy = GameObject.FindGameObjectWithTag("Player").transform; buddyScript = playerBuddy.GetComponent<Movement>(); }
void FixedUpdate() { if (GetDistanceToPlayer() < AttackRange && state == ChaseState.Chase) { state = ChaseState.Attack; animator.SetTrigger("Attack"); } }
void Awake() { chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); }
void Awake() { alertState = new AlertState(this); attackState = new AttackState(this); chaseState = new ChaseState(this); patrolState = new PatrolState(this); navMeshAgent = GetComponent <NavMeshAgent> (); }
// This function basically initializes the instance if it doesnt exist, // otherwise return the already initialzed instance to keep re-using the // same instance. public static ChaseState getInstance() { if (instance == null) { instance = new ChaseState(); } return(instance); }
IEnumerator SutanTime() { currentChaseState = ChaseState.Stop; yield return(new WaitForSeconds(wait)); currentChaseState = ChaseState.Normal; yield break; }
private void Awake() { attackState = new AttackState(this); chaseState = new ChaseState(this); patrolState = new PatrolState(this); currentState = patrolState; }
void Awake() { theController = GetComponent <NpcMovement>(); patrolState = new PatrolState(this, theController); chaseState = new ChaseState(this, theController); controlledState = new ControlledState(this, theController); }
private void Awake() { chaseState = new ChaseState(this); alertState = new AlertState(this); patrolState = new PatrolState(this); navMeshAgent = GetComponent <NavMeshAgent> (); }
private void ConstructFSM() { //Get the list of points // pointList = GameObject.FindGameObjectsWithTag("WandarPoint"); var pointList = gameObject.transform.Cast <Transform>().Where(c => c.gameObject.tag == "WandarPoint").Select(c => c.gameObject).ToArray(); Transform[] waypoints = new Transform[pointList.Length]; int i = 0; foreach (GameObject obj in pointList) { obj.GetComponent <Transform>().position = transform.position + new Vector3(Random.onUnitSphere.x * 5, Random.onUnitSphere.y * 5, Random.onUnitSphere.z * 5); waypoints[i] = obj.transform; // waypoints[i].position = new Vector3(Random.insideUnitSphere.x * 5, // Random.insideUnitSphere.z * 5, Random.insideUnitSphere.z * 5); i++; } PatrolState patrol = new PatrolState(waypoints); patrol.AddTransition(FSMTransition.PlayerSeen, StateID.Chasing); patrol.AddTransition(FSMTransition.NoHealth, StateID.Dead); patrol.SetStateDistances(chaseStartDist, attackStartDist); patrol.SetSpeed(speed / 2, rotationSpeed / 2); patrol.SetBounds(patrolBounds.x, patrolBounds.y, patrolBounds.z); ChaseState chase = new ChaseState(waypoints); chase.AddTransition(FSMTransition.PlayerLost, StateID.Patrolling); chase.AddTransition(FSMTransition.PlayerReached, StateID.Attacking); chase.AddTransition(FSMTransition.NoHealth, StateID.Dead); chase.SetStateDistances(chaseStartDist, attackStartDist); chase.SetSpeed(speed, rotationSpeed); AttackState attack = new AttackState(waypoints); attack.AddTransition(FSMTransition.PlayerLost, StateID.Patrolling); attack.AddTransition(FSMTransition.PlayerSeen, StateID.Chasing); attack.AddTransition(FSMTransition.NoHealth, StateID.Dead); attack.SetStateDistances(chaseStartDist, attackStartDist); attack.SetSpeed(speed, rotationSpeed); attack.kamikaze = this.kamikaze; DeadState dead = new DeadState(); dead.AddTransition(FSMTransition.NoHealth, StateID.Dead); AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); //Start patrolling at given points patrol.FindNextPoint(); }
/// <summary> /// Evaluates the update. /// </summary> /// <param name="timeSpan">The time span.</param> public void EvaluateUpdate(TimeSpan timeSpan) { if (this.Strategy.TargetDetected(timeSpan)) { this.State = ChaseState.Chasing; this.Strategy.Chase(timeSpan); } else { this.State = ChaseState.Moving; this.MoveBehavior.Move(timeSpan); } }
private void Awake() { chaseState = new ChaseState(this); patrolState = new PatrolState(this); guardState = new GuardState(this); dazedState = new DazedState(this); distractedState = new DistractedState(this); searchingState = new SearchingState(this); suspiciousState = new SuspiciousState(this); koState = new KOState(this); walkState = new WalkState(this); pointSearchState = new PointSearchState(this); navMeshAgent = GetComponent<NavMeshAgent>(); player = GameObject.FindGameObjectWithTag("Player"); Path = Pathways[0]; AIPath CheckpointScript = Path.GetComponent<AIPath>(); navPoint = CheckpointScript.getPoints()[0]; currentState = patrolState; //sets the current state NoOcclusionLM = 1 << noOcclusionLayer; NoOcclusionLM = ~NoOcclusionLM; }
public void Start() { chaseState = gameObject.GetComponent<ChaseState>(); // set position for wall occlusion pivotPoint = chaseState.target.transform; if (crosshairImage == null) { Debug.LogError("Crosshair texture for ZoomState is not set!"); } }
/// <summary> /// Get the various Components. /// Create the possible States.</summary> public virtual void Awake() { // Get the necessary Components _navMeshAgent = GetComponent<NavMeshAgent>(); _inventory = GetComponent<Inventory>(); // Initialize necessary properties _enemies = new List<Character>(); _interactingCharacters = new List<Character>(); // Initialize the Stats Stats = Instantiate(_stats); Stats.Character = this; // Initialize the States _idleState = new IdleState(this); _alertState = new AlertState(this); _chaseState = new ChaseState(this); _attackState = new AttackState(this); _dyingState = new DyingState(this); _moveState = new MoveState(this); }
/// <summary> /// Awake this instance. /// </summary> private void Awake() { GameObject pathFinding = GameObject.Find("Pathfinding"); enemy = GetComponent<HorrorAI>(); grid = pathFinding.GetComponent<Grid>(); enemySight = GetComponent<EnemySight> (); chaseState = new ChaseState(this, enemy); alertState = new AlertState(this, enemy); patrolState = new PatrolState(this, enemy, grid); pathfindingStrategy = "A*"; processedActions = new Queue<TreeAction>(); }
private void ConstructFSM() { //Get the list of points // pointList = GameObject.FindGameObjectsWithTag("WandarPoint"); var pointList = gameObject.transform.Cast<Transform>().Where(c => c.gameObject.tag == "WandarPoint").Select(c => c.gameObject).ToArray(); Transform[] waypoints = new Transform[pointList.Length]; int i = 0; foreach (GameObject obj in pointList) { obj.GetComponent<Transform>().position = transform.position + new Vector3(Random.onUnitSphere.x * 5, Random.onUnitSphere.y * 5, Random.onUnitSphere.z * 5); waypoints[i] = obj.transform; // waypoints[i].position = new Vector3(Random.insideUnitSphere.x * 5, // Random.insideUnitSphere.z * 5, Random.insideUnitSphere.z * 5); i++; } PatrolState patrol = new PatrolState(waypoints); patrol.AddTransition(FSMTransition.PlayerSeen, StateID.Chasing); patrol.AddTransition(FSMTransition.NoHealth, StateID.Dead); patrol.SetStateDistances(chaseStartDist, attackStartDist); patrol.SetSpeed(speed / 2, rotationSpeed / 2); patrol.SetBounds(patrolBounds.x, patrolBounds.y, patrolBounds.z); ChaseState chase = new ChaseState(waypoints); chase.AddTransition(FSMTransition.PlayerLost, StateID.Patrolling); chase.AddTransition(FSMTransition.PlayerReached, StateID.Attacking); chase.AddTransition(FSMTransition.NoHealth, StateID.Dead); chase.SetStateDistances(chaseStartDist, attackStartDist); chase.SetSpeed(speed, rotationSpeed); AttackState attack = new AttackState(waypoints); attack.AddTransition(FSMTransition.PlayerLost, StateID.Patrolling); attack.AddTransition(FSMTransition.PlayerSeen, StateID.Chasing); attack.AddTransition(FSMTransition.NoHealth, StateID.Dead); attack.SetStateDistances(chaseStartDist, attackStartDist); attack.SetSpeed(speed, rotationSpeed); attack.kamikaze = this.kamikaze; DeadState dead = new DeadState(); dead.AddTransition(FSMTransition.NoHealth, StateID.Dead); AddFSMState(patrol); AddFSMState(chase); AddFSMState(attack); AddFSMState(dead); //Start patrolling at given points patrol.FindNextPoint(); }