HTC Vive Tutorial for Unity

@blackdragonbe

Hi,

with the new Unity 5.6, even with the Steam Vr_Update Poses on Camera (eye), it doesnā€™t work. Actually on this version, the controllers seems jumping really fast on different positions and the object connected with the fixed joint when grabbed jump merrily everywhere :slight_smile:

So do you have a solution or any idea ?

Cheers !

@skylabs01

Wow that definitely shouldnā€™t happen. Does it do this when you run the final project as well? This sounds like a collider/rigidbody problem, could it be possible the colliders on the controllers arenā€™t marked as triggers?

Cheers!

@blackdragonbe

Collider & Rigibody are good.

It seems that other people have the same problems even with the add of the updates poses to the camera eye :

Yes I am banging my head on this one. I load the version 5.5 project and the controllers work (I can grab and teleport) but some of my objects lost textures. I upgrade Unity to 5.6 and load my project and the objects have textures but my controllers dont show up anymore. I will try your suggestion and report back.

Hi, Iā€™m really happy to have found this article & tutorial as Iā€™m just beginning my VR development experience. I noticed something odd that others havenā€™t mentioned and I think Iā€™m doing it correctly. Iā€™m using Unity 5.6.0f3 and Iā€™m getting the following error when entering

void Awake()
{
    trackedObj = GetComponent();
}

Assets/Scripts/ViveControllerInputTest.cs(18,22): error CS0305: Using the generic method UnityEngine.Component.GetComponent<T>()' requires 1ā€™ type argument(s)

I placed it just above the Update void:

void Awake()
{
    trackedObj = GetComponent();
}
// Update is called once per frame
void Update()
{

@altrageous This is the correct code:

 void Awake()
{
   trackedObj = GetComponent<SteamVR_TrackedObject>();
}

You may want to start with the scripting tutorial before diving into VR to avoid mistakes like these.

@skylabs01 @stephanfitch
I still have to check what exactly has been broken by 5.6 for this tutorial, it seems it introduced more bugs than I expected. Let me know if you guys find any solutions.

Cheers!

Are we getting any closer to finding out what went loopy with 5.60f3 that caused our controller scripts to take a hiatus from the scene? . I tried adding update poses to camera eye and suddenly I could see their shadows in the scene. I looked up to see them floating above my head. The laser and reticle appear when I trigger, but teleporting isnā€™t working. Hummm? Any ideas?

@stephanfitch

Iā€™ll see if I can take a look when I get home. It sounds like their position is being offset or something.
Iā€™m working on the next Vive tutorial at the moment (in 5.6) and everything works once I add the poses script to the camera eye.
This leads me to believe my code for this one might be relying on something that has been broken in the new version. Hopefully itā€™s a quick fix.

Cheers!

@skylabs01 @stephanfitch
Iā€™ve found the issue. It seems something about how layers are saved has changed in the newest version of Unity.
Can you guys expand the Level GameObject, select Floor and set its layer to CanTeleport again? I know itā€™s already set to CanTeleport, but for some reason this fixes it.

I also did the following:

  • Updated SteamVR (delete the SteamVR folder from the Assets folder first!)
  • Deleted Main Camera (not needed)
  • Added Steam VR_Update Poses component to [CameraRig] \ Camera (head) \ Camera (eye).

Iā€™ll do a quick update to the tutorial with this fix included. Iā€™m planning on doing a big update to this tutorial soon as well.

Cheers!

Thanks Eric. I will try it. Was there anything specific about the CanTeleport layer? I donā€™t think your tutorial shared information about this? It was a component of your tutorial without details.

@stephanfitch
Youā€™re welcome.

That layer is referenced at the end of the tutorial, itā€™s used by the Teleport Mask to decide what objects you can use the laser/teleport on. Itā€™s just a simple layer used as a flag I added beforehand to keep things simple, I never expected it to have an impact like this after a Unity update.

Anyway, hope this helped.

Cheers

Hi @blackdragonbe,

thank you for the fix. But the problem was with the grabbing object and youā€™re talking of the can teleport layer. I donā€™t see what is the link with the shaking controller ^^

Can you grab and play smoothly with your controller and object with your scene in Unity 5.6 ?

Best regards

Hey @skylabs01,

The grabbing worked perfectly fine for me.
Can you try the following:

  • Update Steam
  • Update SteamVR (enable the beta as well, see https://www.reddit.com/r/Vive/comments/4lc578/how_to_enable_steamvr_beta/)
  • Update the controller and HMD firmware using the SteamVR desktop app (SteamVR > Devices > Update Firmware)
  • Open the final project in Unity, let it upgrade to 5.6
  • Add the Update_Poses component to Camera (eye)
  • Update the SteamVR unity plugin to the newest version from the Asset Store

That should make your environment about the same as mine. Let me know if that helps!
Also be sure to try playing a Vive game and see if youā€™ve got the issue there too, if yes, itā€™s almost definitely a firmware issue.

Cheers!

Hi @blackdragonbe,

I am also experiencing the same grabbing issue as @skylabs01; I cannot pick up objects. I have an executable of my project made in 5.5, and the grabbing works fine within that game. I have done everything youā€™ve listed. Teleportation works for me.

Do you have any other suggestions? I really appreciate your help!

Thanks!

Edit: Heh. Fixed. I forgot to add the Rigidbody and box collider to the controller; everything is fine!

Dears, my problem is that I cannot see trackers in the headset (or play view), only in the scene view ;/ When I press the ā€œoptionā€ button, the trackers reapear in the headset with menu showing, but disapear once I hide the menu. Any help is greatly appreciated.

PS: The tracking in the scene view is also a bit weird, since controllers seems to be parented to camera so they move with camera.

@tomitrescak
Could you try adding a Steam Vr_Update Poses component to [CameraRig] \ Camera (head) \ Camera (eye) and see if that helps? Some weird bugs were introduced since Unity 5.6.

Cheers!

Hey fgamerz303, for this issue, within void Update() add:

void Update()
{
    if (Controller.GetPress(SteamVR_Controller.ButtonMask.Touchpad))
    {
        RaycastHit hit;

        if (Physics.Raycast(trackedObj.transform.position, transform.forward, out hit, 100))
        {
            hitPoint = hit.point;
            ShowLaser(hit);
        }
        else
        {
            laser.SetActive(false);
        }
    }
    **else**

** {**
** laser.SetActive(false);**
** }**
}

1 Like

Thanks for that solution!
Mustā€™ve been on oversight on my part.
Iā€™ll include that in the next update of this tutorial.

Cheers!

I ran into this with Unity 5.6.1f1, adding the Update_poses to the cameras didnā€™t work either, no matter where I added it (there are tons of posts explaining different ways to do this). In the end I had to pull fix #14 into the SteamVR asset straight from github. Fix SteamVR_UpdatePoses to work with every Unity version. by bddckr Ā· Pull Request #14 Ā· ValveSoftware/steamvr_unity_plugin Ā· GitHub

WOW very nicely done tutorial, I too had to make some changes to make the controllers show up, and they are just white ghost shapes at the moment but its all good and all a learning experience!!!..
OK Now for the minor criticism, The one thing I have always disliked about this type of tutorial is that there is A LOT of prework that you put into getting this ready for us to download and start.
Do you have another tutorial that shows how you did that? I would really like to see a here is what I did to begin with a brand new install of Unity.
Now when I start fresh I might have some clue how to go from point A to B, also what would be helpful is how to go from C to D, as in I have a completed "game or project now howdo I export everything needed to send to Steam or a friend to ā€œplayā€ it???
BUT again this is great and my first time I got to do a AHA! moment with programming for this.

I have downloaded and installed blender and Google sketch up as I am fairly sure they will be great tools for making the 3D objects for use in VR Games / projects, anyone have any other must have programs I need to check out.