How to create a VR Health Bar?

as the title, someone please help me ?

My Health Script :

#pragma strict

var Health = 100;

function ApplyDammage (TheDammage : int)
{
    Health -= TheDammage;
   
    if(Health <= 0)
    {
        Dead();
    }
}

function Dead()
{
    Destroy (gameObject);
}

I’m pretty curious about this as well. Or how you’d use the new UI system that was introduced in 4.6 with VR.

It can’t be that hard to adjust a normal UI for VR can it?

U have to set the UI to “world space” and give the UI a nice place in the scene. :slight_smile:

So far I tried;

GUI: Doesn’t work in VR

Canvas: Great for everything except anything that needs to be animated or change a lot. You can’t just draw your health bar to a canvas texture the same way you would with GUI. You could make a bunch of little textures and have them disable and enable based on player health.

Planes and geometry: I like just slapping planes as children to the VR cam and controlling if they are visible or not with scripts. It’s very simplistic, such as the canvas example above. I built my main menu this way a long time ago and after making the project VR, I found that it works very well.

Render to Texture: I haven’t figured out how to use this or what it does.

What’s wrong with a method like this?

1 Like