Hello
so I have this script. It works great on the old ovr rig. Just assign it to the rig, and drag in the mid camera part and the left hand.
How do I go about turning this to a Unity XR script? Also, would I even be able to attach to the highest part of the xr rig, and have it work like the ovr rig initially did? Sorry, im a noob.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Fly : MonoBehaviour
{
public GameObject head;
public GameObject leftHand;
private float flyingSpeed = .5f;
private bool isFlying = false;
// Update is called once per frame
void Update()
{
CheckIfFlying();
FlyIfFlying();
}
private void CheckIfFlying()
{
if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.LTouch))
{
isFlying = true;
}
if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger, OVRInput.Controller.LTouch))
{
isFlying = false;
}
}
private void FlyIfFlying()
{
if (isFlying == true)
{
Vector3 flyDirection = leftHand.transform.position - head.transform.position;
transform.position += flyDirection.normalized * flyingSpeed;
}
}
}
6717637–772600–Fly.cs (1008 Bytes)