public void FollowPlayer() { Debug.Log("Following..."); _agent.SetDestination(player.transform.position); if (stun.isStun == false) { _gun.Shoot(); } }
public override void Update() { base.Update(); //transform.LookAt(player.transform); if (selectedState == state.Shoot) { eg.Shoot(); } }
IEnumerator ShootPlayer() { EnemyGun enemyGun = childTransform.gameObject.GetComponent <EnemyGun>(); myTransform.LookAt(player); enemyGun.Shoot(); yield return(new WaitForSeconds(shootingFrequency)); myTransform.LookAt(player); enemyGun.Shoot(); yield return(new WaitForSeconds(shootingFrequency)); myTransform.LookAt(player); enemyGun.Shoot(); yield return(new WaitForSeconds(shootingFrequency * 3)); shooting = false; // EnemyGun shoots in the direction the enemy is facing }
private void Attack(Castle target) { _animator.speed = 1 / _attackDelay; _animator.Play("Attack"); if (_miliAttackType) { target.TakeDamage(_damage); } else { _weapon.Shoot(_shootPoint); } }
// Update is called once per frame void Update() { if (!seenPlayer && !shot) { Debug.DrawRay(this.gameObject.transform.position, this.transform.forward, Color.yellow, range); RaycastHit hit; if (!seenPlayer && Physics.Raycast(this.gameObject.transform.position, this.transform.forward, out hit, range, playerLayer)) { seenPlayer = true; StartCoroutine(gun.Shoot()); } } if (seenPlayer || shot) { nav.SetDestination(player.position); } }