Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Virtual Reality VR in Unity VR Setup HTC Vive Setup

Harrison Bolin
Harrison Bolin
3,975 Points

I'm getting an error trying to run the project at this point

When I run the game for the first time, I get the following error:

Assets/Scripts/VRAdjustment.cs(30,31): error CS0029: Cannot implicitly convert type UnityEngine.Vector3' toUnityEngine.Quaternion'

using UnityEngine;
using System.Collections;
using UnityEngine.VR;

public class VRAdjustment : MonoBehaviour {

    private Vector3 monitorRotation = new Vector3 (-12f, 0f, 0f);
    private Vector3 openVRPosition = new Vector3 (0f, -1.75f, 0f);


    // Use this for initialization
    void Awake () {

        // If there is no VR device at the start of the game:
        if (!VRDevice.isPresent) {

            //tilt camera upward for monitor view
            transform.localRotation = Quaternion.Euler (monitorRotation);

        } else {

            //Otherwise, if VR Device available and is OpenVR
            if (VRSettings.loadedDeviceName == "OpenVR") {

                //Then move camera to floor
                transform.localRotation = openVRPosition;
            }

        }
    }

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

        //If reset of camera needed
        if (Input.GetKeyUp (KeyCode.R)) {

            InputTracking.Recenter ();

        }

    }


    void OnApplicationQuit () {

        // When app quit, disable VR
        VRSettings.enabled = false;


    }
 }

That's the code I typed. Is something wrong?

1 Answer

Harrison Bolin
Harrison Bolin
3,975 Points

Found the problem. In line 26, I had written "transform.localRotation" instead of transform.localPosition