Files
RoomAwareVR/Assets/Fragilem17/Portals for VR/Scripts/StraightenTrackingSpace.cs
T
2025-05-26 00:46:28 +02:00

46 lines
773 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Fragilem17.MirrorsAndPortals
{
public class StraightenTrackingSpace : MonoBehaviour
{
public float speed = 1f;
public bool useLateUpdate = true;
public bool useLerp = true;
private void Update()
{
if (!useLateUpdate)
{
Straighten();
}
}
void LateUpdate()
{
if (useLateUpdate)
{
Straighten();
}
}
private void Straighten()
{
Vector3 euler = transform.rotation.eulerAngles;
if (useLerp)
{
transform.rotation = Quaternion.LerpUnclamped(transform.rotation, Quaternion.Euler(0, euler.y, 0), speed * Time.deltaTime);
}
else
{
transform.rotation = Quaternion.Euler(0, euler.y, 0);
}
}
}
}