45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using UnityEngine;
|
|
|
|
public class StaircaseDistortion : MonoBehaviour
|
|
{
|
|
[Header("The Vertigo Effect")]
|
|
public float normalFOV = 60f;
|
|
public float stretchedFOV = 110f; // High FOV makes things look far away
|
|
public float transitionSpeed = 0.5f;
|
|
|
|
private Camera playerCam;
|
|
private bool isOnStairs = false;
|
|
|
|
void Update()
|
|
{
|
|
if (playerCam == null) return;
|
|
|
|
if (isOnStairs)
|
|
{
|
|
// Slowly widen the view (Stretch)
|
|
playerCam.fieldOfView = Mathf.Lerp(playerCam.fieldOfView, stretchedFOV, Time.deltaTime * transitionSpeed);
|
|
}
|
|
else
|
|
{
|
|
// Return to normal
|
|
playerCam.fieldOfView = Mathf.Lerp(playerCam.fieldOfView, normalFOV, Time.deltaTime * 2f);
|
|
}
|
|
}
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
{
|
|
playerCam = Camera.main; // Find the camera
|
|
isOnStairs = true;
|
|
}
|
|
}
|
|
|
|
void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
{
|
|
isOnStairs = false;
|
|
}
|
|
}
|
|
} |