using UnityEngine; public class PlayerCamera : MonoBehaviour { public GameObject playerObject; public float normalMinYFollow = 2.0f; public float shipMinYFollow = 6.0f; private float initialY; private void Start() { initialY = transform.position.y; } private void Update() { Player player = playerObject.GetComponent(); float minYFollow = normalMinYFollow; if (player.CurrentGameMode is ShipGameMode) { minYFollow = shipMinYFollow; } float targetY = initialY; if (playerObject.transform.position.y > minYFollow) { targetY = playerObject.transform.position.y; } transform.position = new Vector3(playerObject.transform.position.x, targetY, transform.position.z); } }