Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VR score text display

I am trying to make a VR game with google cardboard in unity. However we can not find a way to display score text right in front of the player. However when I add 2D text it is only on one side and therefore on one side of the eye and getting the position right for 2 texts is hard. If I use 3D text and set in front of the players position I think it will go into the wall if a player hits one. Is their any way to display a score on google cardboard / Unity VR.

like image 994
Hans.Gundlach Avatar asked Nov 08 '15 09:11

Hans.Gundlach


2 Answers

You can either use native Unity Canvas UI or Googles hack to render OnGUI calls onto a texture.

I would definately recommend Canvas as that is the way Unity is working on their UI features, and it has much better layout capability.

To use canvas, Right click in the hierarchy and add UI->Text. You will automatically get a canvas. The important part is set the canvas to world-space (not screen space overlay). Then drag the canvas game object so it is a child of the Google Cardboard Main head object. Scale it down (like x:0.001,y:0.001,z=0.001) because by default it will be massive. To avoid going through walls position it about 0.5m in front of the camera - within any collider you may have.

like image 95
peterept Avatar answered Nov 18 '22 08:11

peterept


there is another approach as well which you can place that canvas under camera make it world space, and then adjust it as you want, after that where ever you look at it will be seen easily enter image description here ( as suggested by earlier user in answers) as you can see below in picture i placed canvas > Text > under camera which i used for oculus/ google camera

like image 1
Maaz Irfan Avatar answered Nov 18 '22 06:11

Maaz Irfan