void OnTriggerEnter(Collider other) { if (other.gameObject.GetComponent <AIPathfinding>()) { Instructable = other.gameObject.GetComponent <AIPathfinding>(); Instructable.SetWaypoint(nextTarget.transform.position + new Vector3(Random.Range(-RandomizePosRange, RandomizePosRange), 0, Random.Range(-RandomizePosRange, RandomizePosRange))); } }
private void Start() { //Init current state to wander, as we don't know if we //can see the player when we start currentAIState = AI_STATE.AI_STATE_WANDER; //Init Target Pos and prev target to be our current position prevTargetPos = targetPos = transform.position; //Get required pathfinding component pathfinder = GetComponent <AIPathfinding>(); //Find the player object if there is not one already assigned if (playerObject == null) { playerObject = FindObjectOfType <PlayerData>().gameObject; } }
private new void Awake() { base.Awake(); pathfinding = GetComponent <AIPathfinding>(); }
void Start() { pathScript = gameObject.GetComponent <AIPathfinding>(); EnemyCurrentHealth = EnemyMaxHealth; }