Autowalk in VR (Cardboard) in Unity 2018.2,Autowalk in VR (Cardboard) in 2018.2
I was following a tutorial on how to build a VR Maze game in Unity for Google Cardboard. The player is to move in the direction the camera is pointed. The tutorial was recorded in an older version of Unity, but I am using 2018.2. I have followed the tutorial exactly, however, I cannot get the camera to move, in either Play-mode or in the Build. I am not sure what I need to change to get this to work. When I enter play mode the camera does not move. I keep getting a Null Reference error.
Here is my code.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class AutoWalk : MonoBehaviour { public int speed = 3; // Use this for initialization void Start () {
}
// Update is called once per frame
void Update () {
transform.position = transform.position + (Camera.main.transform.forward * speed * Time.deltaTime);
}
}
Here is the error
NullReferenceException: Object reference not set to an instance of an object AutoWalk.Update () (at Assets/DataFiles/Scripts/AutoWalk.cs:14)
The errors occur every frame/update while in play mode. I am a beginner trying to learn, so any help would be greatly appreciated.
Thanks, Steve ,I was following a tutorial that creates a maze and the camera moves in whichever direction the camera is pointed. The tutorial was recorded in an older version of Unity. I copied the script word-for-word, but the camera does not move in Play-mode or in the build. I keep getting a Null Reference error.
Here is the code:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class AutoWalk : MonoBehaviour { public int speed = 3; // Use this for initialization void Start () {
}
// Update is called once per frame
void Update () {
transform.position = transform.position + (Camera.main.transform.forward * speed * Time.deltaTime);
}
}
Here is the error NullReferenceException: Object reference not set to an instance of an object AutoWalk.Update () (at Assets/DataFiles/Scripts/AutoWalk.cs:14)