I tried to follow this tutorial on youtube to be able to walk through my animation in Unity.
I followed this tutorial on how to:
Unfortunately it does not work and I am thrown this error:
UnassignedReferenceException: The variable vrCamera of VRLookWalk has not been assigned.
You probably need to assign the vrCamera variable of the VRLookWalk script in the inspector.
How can I fix it? What am I doing wrong? Can somebody please tell me what I should type instead?
My code looks like the one in the tutorial, but maybe I have missed something, eventhough I have doublechecked many times.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VRLookWalk : MonoBehaviour {
public Transform vrCamera;
public float toggleAngle = 30.0f;
public float speed = 3.0f;
public bool moveForward;
private CharacterController cc;
// Start is called before the first frame update
void Start (){
cc = GetComponent();
}
// Update is called once per frame
void Update () {
if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f){
moveForward = true;
}
else {
moveForward = false;
}
if (moveForward) {
Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
I have dragged it there, but I still cant move. It is called camera in the left pane, so instead of calling it vrCamera in the code, should I then change it to camera?
Add “Debug.Log” is a debug procedure to verify why it’s not work.
Press Ctrl+Shift+C to open unity’s console window and run, then move the camera and check the console output to see the value of eulerAngles.x. The moveForward will be true while the eulerAngles.x is between toggleAngle and 90.0f degrees.
Could it be because there is something I havent downloaded from the store? Or is it because my script is “greyed out” in the inspector and that does something to it? (the text is not black as the rest)