RoadRunner/Assets/script/RecenterOrigin.cs
Kasper Karlgren c84494a697 new files
2025-01-21 13:54:40 +01:00

35 lines
760 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using Unity.XR.CoreUtils;
public class RecenterOrigin : MonoBehaviour
{
public Transform head;
public Transform origin;
public Transform target;
public InputActionProperty recenterButton;
public void Start()
{
}
public void Recenter()
{
XROrigin xrOrigin = GetComponent<XROrigin>();
xrOrigin.MoveCameraToWorldLocation(target.position);
xrOrigin.MatchOriginUpCameraForward(target.up,target.forward);
}
// Update is called once per frame
void Update()
{
if (recenterButton.action.WasPressedThisFrame())
{
Recenter();
}
}
}