I have a script for VR movement using the built in VR, but there’s no errors, and still works, but it doesn’t move in the right direction; It uses the new Input System.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class XRController : MonoBehaviour
{
private Movement move;
private Movement.OnFootActions onFoot;
public GameObject Rig;
private Vector2 input;
private Vector3 Direction;
public float speed = 6.0f;
public GameObject Cam;
public CharacterController controller;
public float rot;
// Start is called before the first frame update
void Awake()
{
move = new Movement();
onFoot = move.OnFoot;
controller = Rig.GetComponent<CharacterController>();
}
// Update is called once per frame
void Update()
{
rot = Cam.transform.localRotation.eulerAngles.y;
onFoot.Enable();
input = (onFoot.Movement.ReadValue<Vector2>());
Direction = Vector3.zero;
Direction.x = input.x;
Direction.z = input.y;
transform.eulerAngles = (new Vector3(0, rot, 0));
controller.Move(transform.TransformDirection(Direction) * speed * Time.deltaTime);
}
}
Cam – XR camera
rot – XR camera Y rotation
Rig – XRRig