Continued working on the lights, set up playable version and turn trap at the end of the stairs. Working on making stairs feel longer.
This commit is contained in:
45
Assets/Scripts/StaircaseDistortion.cs
Normal file
45
Assets/Scripts/StaircaseDistortion.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user