Issues with movement & headYaw

Hi!

Following a tutorial on how to built continous movement in unity. All worked well before I added HeadYaw.
Full code:

Code (CSharp):
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;


public class ContinousMovement : MonoBehaviour
{
  
    public float speed = 1;
    public XRNode inputSource;
    public LayerMask groundLayer;

    private XRRig rig;
    private Vector2 inputAxis;
    private CharacterController character;

    // Start is called before the first frame update
    void Start()
    {
        character = GetComponent<CharacterController>();
        rig = GetComponent<XRRig>();
    }

    // Update is called once per frame
    void Update()
    {

       InputDevice device = InputDevices.GetDeviceAtXRNode(inputSource);
       device.TryGetFeatureValue(CommonUsages.primary2DAxis, out inputAxis);
    }

    private void FixedUpdate()
    {

        Quaternion headYaw = Quaternion.Euler(0, rig.cameraGameObject.transform.eulerAngles.y, 0);

        Vector3 direction = headYaw * new Vector3(inputAxis.x, 0, inputAxis.y);

        character.Move(direction * Time.fixedDeltaTime * speed);
      


    }

}

On private void FixedUpdate, if I delete the first line fully (Quaternion headYaw…) and on second line delete “headYaw *” - I can move again. Why is this? Trying to get the movement to follow my headset.
Any advice on how to tackle this?
Thanks!

Hi,

Are you sure rig.cameraGameObject.transform.eulerAngles.y returns the values you expect?

thanks for the answer!

Do you mean checking it through input debugger?

Have you checked the console log? Perhaps there are some errors going on.