//STATE MACHINE STATE DEFINITIONS void Idle() { //If the player is within a certain distance move towards them //Eventually this will just be on room enter. /*if(Vector3.Distance(this.transform.position,target.transform.position) < 1.0) * { * state = enemyMelee.State.CHASE; * } * else * { * agent.SetDestination(this.transform.position); * }*/ agent.speed = speedIdle; animator.SetTrigger("Idle"); if (Vector3.Distance(this.transform.position, target.transform.position) < 1.0) { state = enemyMelee.State.CHASE; } else if (Vector3.Distance(this.transform.position, this.patrolPosition.position) >= 0.5) { agent.SetDestination(patrolPosition.position); } else if (Vector3.Distance(this.transform.position, this.patrolPosition.position) < 0.5) { patrolPosition = enemyWaypoint.nextWaypoint(); } }
//STATE MACHINE STATE DEFINITIONS void Idle() { //If the player is within a certain distance move towards them //Eventually this will just be on room enter. this.transform.GetChild(0).GetComponent <enemyRangeLook>().updateMaterial(0); //if(Vector3.Distance(this.transform.position,target.transform.position) < 1.5) //{ //state = enemyRanged.State.CHASE; //} agent.speed = speedIdle; if (Vector3.Distance(this.transform.position, target.transform.position) < 1.5) { state = enemyRanged.State.CHASE; } else if (Vector3.Distance(this.transform.position, this.patrolPosition.position) >= 0.5) { agent.SetDestination(patrolPosition.position); } else if (Vector3.Distance(this.transform.position, this.patrolPosition.position) < 0.5) { patrolPosition = enemyWaypoint.nextWaypoint(); } }
void Awake() { enemyWaypoint = gameObject.transform.parent.GetChild(0).GetComponent <enemyWaypoint>(); patrolPosition = enemyWaypoint.nextWaypoint(); }