Log in or register to post comments

3D or 2D UI text constantly facing the camera.

December 10, 2018 - 8:40am #1

Hi there! 

 

I'm trying to make a scene where a panel of text appears on detection of a single image target and is constantly facing the camera/device while it is being moved around the image. 

I want it to stay in the same location within the 3D space, but just to rotate to face the camera depending on its movement.

I've tried a couple scripts that would seem to work in a normal Unity game scene, but don't seem to work when put into a Vuforia controlled scene.

I've attached a screenshot of the sort of thing I was thinking of.

(Vuforia video for reference: https://www.youtube.com/watch?v=6W7_ZssUTDQ)

 

Any help would be much appreciated.

Thanks

AttachmentSize
Image icon Text_Camera_Example.png730.63 KB

3D or 2D UI text constantly facing the camera.

December 12, 2018 - 6:58am #6

So I followed your instructions and that seems to work (the cube constantly faces the camera).

I've now tried applying it to a UI Canvas and the text within the Canvas does follow the camera, but the only problem is that the text is the wrong way round. I've tried to rotate the canvas/text by 180 in editor and have tried rotating it on start within the script, but neither of these seem to work.

Probably missing something very easy.

3D or 2D UI text constantly facing the camera.

December 11, 2018 - 1:14pm #5

Hello,

I would also suggest reviewing the VuMark feature of the Vuforia Core Samples, which can be downloaded from the Unity Asset Store. The augmentations when tracking a VuMark have mock information windows that demonstrate a similar behavior.

Thanks,

Vuforia Engine Support

3D or 2D UI text constantly facing the camera.

December 11, 2018 - 11:07am #4

Lets try and see what you are doing wrong.  Follow these steps:

1. New scene

2. Add an ARCamera and Image Target, set target in the inspector for your image target.

3. Add a cube and parent it to the image target

4. Add the script below to cube

5. Drag camera the arcamera to the inspector in the new script

6. Make sure world center mode is first target.



Press play in editor and move your webcam around you image target, the cube should face the camera.

using UnityEngine;
using System.Collections;

public class LookAtCamera : MonoBehaviour
{
public Transform cam;
void Update()
{
  transform.LookAt(cam);
}
}

3D or 2D UI text constantly facing the camera.

December 11, 2018 - 8:01am #3

Hi. 

I've just tried this, but it doesn't seem to do anything new for me. The text is still staying attached to the image target and not focusing on the camera.

3D or 2D UI text constantly facing the camera.

December 10, 2018 - 11:38am #2

Check to make sure World Center Mode on your AR camera is set to First Target.  

 

 

Log in or register to post comments