bugfix/fix-ship (#49)

Co-authored-by: Djelal BOUDJI <djelal@gmail.com>
This commit is contained in:
djelalb
2025-03-31 09:57:45 +02:00
committed by GitHub
parent d57cc647aa
commit aa6401f6bc
4 changed files with 61 additions and 34 deletions

View File

@ -3,7 +3,8 @@ using UnityEngine;
public class PlayerCamera : MonoBehaviour
{
public GameObject playerObject;
public const float MIN_Y_FOLLOW = 2.0f;
public float normalMinYFollow = 2.0f;
public float shipMinYFollow = 6.0f;
private float initialY;
private void Start()
@ -13,9 +14,16 @@ public class PlayerCamera : MonoBehaviour
private void Update()
{
float targetY = initialY;
Player player = playerObject.GetComponent<Player>();
if (playerObject.transform.position.y > MIN_Y_FOLLOW)
float minYFollow = normalMinYFollow;
if (player.CurrentGameMode is ShipGameMode)
{
minYFollow = shipMinYFollow;
}
float targetY = initialY;
if (playerObject.transform.position.y > minYFollow)
{
targetY = playerObject.transform.position.y;
}