mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-04-10 21:47:07 +02:00
34 lines
831 B
C#
34 lines
831 B
C#
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<Player>();
|
|
|
|
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);
|
|
}
|
|
}
|