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 VR Camera Setup

Vector 3 Not Recognized

When I created the VR Adjustment Script, Vector 3 was not recognized as an actual command. Did i forget to install a plugin or something? Any help would be very appreciated, thank you. This is the code: using System.Collections; 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 (!VRDevice.isPresent)
    {

        transform.localRotation = Quaternion.Euler(monitorRotation);

    }
    else
    {

        if (VRSettings.loadedDeviceName == "OpenVR")
        {
            transform.localPosition = openVrPosition;

        }

    }

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

        if (Input.GetKeyUp(KeyCode.R))
        {

            InputTracking.Recenter();
        }


    }

    void OnApplicationQuit ()
    {


        VRSettings.enabled = false;

    }

}

It is also saying that the voids in line 34 and 46 cannot be used in their context, and that there were unexpected symbols in those same lines.

3 Answers

K Cleveland
K Cleveland
21,839 Points

It looks like Vector3 is part of the UnityEngine namespace. So just like you have

using System.Collections; 
using UnityEngine.VR;

you'll need to add a using statement for UnityEngine.

For your other question, void Update(), and void OnApplicationQuit() are inside void Awake() -- but you probably don't want that, right?

Good luck!

Thanks!

It seems the only problem i am having at the moment is "The type or namespace 'Vector3' could not be found."

K Cleveland
K Cleveland
21,839 Points

Did you add a using statement for UnityEngine? Thanks!

yes i did, thank you.