private void RotateTowardsTarget() { //gameObject.transform.LookAt(eyes.restingPos.transform); //Vector3 dir = (this.transform.position - eyes.restingPos.transform.position).normalized; if (target.tag == "Player") { //Debug.Log("Enemy direction: " + dir); Vector3 dir = (this.transform.position - target.transform.position).normalized; Vector3 heading = target.transform.position - transform.position; float dirNum = AngleDir(transform.forward, heading, transform.up); if (dirNum > 0) { enemyRB.AddRelativeTorque(dir * rotationStrength, ForceMode.Force); } else if (dirNum < 0) { enemyRB.AddRelativeTorque(dir * -rotationStrength, ForceMode.Force); } if (dirNum > -aimConeSize && dirNum < aimConeSize) { if (enemyGun.canFire) { enemyGun.Fire(); } } } }
void FireAll() { gunScript.Fire(aimAngleH, aimAngleV); /* * public float bulletCountCurrent; * public float fireIntervalCurrent; * public float reloadTimeCurrent;*/ Task.current.debugInfo = string.Format("Bullets: {0} / {1} Reload: {2} / {3}", gunScript.bulletCountCurrent, gunScript.bulletCountMax , gunScript.reloadTimeCurrent, gunScript.reloadTimeMax); if (gunScript.bulletCountCurrent == 0) { Task.current.Succeed(); } }
private void Fire() { FaceToTarget(); gun.Fire(); }
private void AttackBehaviour() { engine.ProcessLook(target); gun.Fire(); }