void TrackClose() { if (obControl.player.isLight) { playerDirection = obControl.playerTarget.transform.position - transform.position; playerDistance = Vector3.Distance(obControl.playerTarget.transform.position, transform.position); playerAngle = Vector3.Angle(playerDirection, transform.forward); // Check if the gun still sees the player. If not, change to SCAN if (playerAngle > detectionAngle) { enemyState = EnemyState.SCAN; } // Check is player is still within close tracking distance. If not, change to TRACK_FAR if (playerDistance > closeTrackDistance) { enemyState = EnemyState.TRACK_FAR; } // Rotate gun to track player position steeringBasics.LookAtDirection(obControl.playerTarget.transform.position); CheckRotationBounds(); // Check if player location is in front of gun and shoot if (steeringBasics.IsInFront(obControl.playerTarget.transform.position)) { shootGun = true; } } else { enemyState = EnemyState.SCAN; } }
void CheckFire(Vector3 target) { bool inFront = steeringBasics.IsInFront(target); if (targetDistance < fireDistance && inFront) { if (secondaryWeapon) { if (shotTimer > 0) { weaponSystems.setState(WeaponSystems.WEAPON.PRIMARY); shotTimer -= Time.deltaTime; } else { if (secondShotTimer > 0) { weaponSystems.setState(WeaponSystems.WEAPON.SECONDARY); secondShotTimer -= Time.deltaTime; } else { shotTimer = maxShotTime; secondShotTimer = maxSecondShotTime; } } } else { weaponSystems.setState(WeaponSystems.WEAPON.PRIMARY); } } }
void TrackClose() { playerDirection = obControl.playerTarget.transform.position - transform.position; playerDistance = Vector3.Distance(obControl.playerTarget.transform.position, transform.position); playerAngle = Vector3.Angle(playerDirection, transform.forward); // Check is player is still within close tracking distance. If not, change to TRACK_FAR if (playerDistance > closeTrackDistance) { enemyState = EnemyState.TRACK_FAR; } // Rotate gun to track player position steeringBasics.LookAtDirection(obControl.playerTarget.transform.position); // Check if player location is in front of gun and shoot if (steeringBasics.IsInFront(obControl.playerTarget.transform.position)) { ShootGun(); } }