private void FireOnPlayers() { var players = GameObject.FindGameObjectsWithTag("Player"); foreach (var player in players) { var playerPosition = player.transform.position; if (!(Vector3.Distance(playerPosition, transform.position) < ActionRadius)) { continue; } var ray = new Ray(transform.position, playerPosition - transform.position); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { if (hit.transform.gameObject != player) { continue; } } _ship.TurnTurrets(playerPosition); _ship.FireTurrets(); return; } }
private void CmdFire(Vector3 aim) { _shipControls.TurnTurrets(aim); _shipControls.FireTurrets(); }