private void Awake() { _aiFieldOfView = GetComponent <AiFieldOfView>(); _aiPathfinding = GetComponent <AiPathfinding>(); _aiAttack = GetComponent <AiAttack>(); _animator = GetComponent <Animator>(); }
public override void Start() { base.Start(); spriteRenderer = GetComponent <SpriteRenderer>(); enemyAttack = gameObject.GetComponent <AiAttack>(); enemyMovement = gameObject.GetComponent <AiMovement>(); colliderList = gameObject.GetComponentsInChildren <Collider2D>(); dataToPassBetweenScenes = GameObject.FindGameObjectWithTag("PassData").GetComponent <DataToPassBetweenScenes>(); player = GameObject.Find("MyCharacter"); }
// Update is called once per frame void Update() { distance = (enemy.position - player.position); distance.y = 0; distanceFrom = distance.magnitude; distance /= distanceFrom; if (distanceFrom < 20) { ProgressAlongPathSpeed speed = GetComponent <ProgressAlongPathSpeed>(); ProgressAlongPathTime time = GetComponent <ProgressAlongPathTime>(); RotateToMovement rotate = GetComponent <RotateToMovement>(); AiAttack attack = GetComponent <AiAttack>(); AIMove move = GetComponent <AIMove>(); speed.enabled = false; time.enabled = false; rotate.enabled = false; attack.enabled = true; move.enabled = true; } else { ProgressAlongPathSpeed speed = GetComponent <ProgressAlongPathSpeed>(); ProgressAlongPathTime time = GetComponent <ProgressAlongPathTime>(); RotateToMovement rotate = GetComponent <RotateToMovement>(); AiAttack attack = GetComponent <AiAttack>(); AIMove move = GetComponent <AIMove>(); speed.enabled = true; time.enabled = true; rotate.enabled = true; attack.enabled = false; move.enabled = false; } }
void Awake() { Player = GameObject.FindWithTag("Player").transform; _enemyattack = GetComponent <AiAttack>(); rb = GetComponent <Rigidbody>(); }