Log in or register to post comments

Face Me

October 10, 2011 - 6:19pm #1

Is there a complete script that one can apply to the AR camera in Unity that will serve as a kind of "face me" script? In other words, when the user walks around the model, the front of the model always faces the users camera vision so the the user always see the same side of the model?

Re: Face Me

February 28, 2012 - 7:33pm #7

Try adding a script like this to the model:

using UnityEngine;

public class LookAtCamera : MonoBehaviour,
                            ITrackerEventHandler
{
    void Start()
    {
        QCARBehaviour qcarBehaviour = (QCARBehaviour) FindObjectOfType(typeof(QCARBehaviour));
        if (qcarBehaviour)
        {
            qcarBehaviour.RegisterTrackerEventHandler(this);
        }
    }

    public void OnTrackablesUpdated()
    {
        transform.LookAt(Camera.main.transform);
    }
}

- Kim

Re: Face Me

February 28, 2012 - 3:07am #6

Hi,
I have the same issue, but I'm new in coding, I tried to implemented the suggested, but without success.
Can you help me on this?
Tks

Re: Face Me

February 14, 2012 - 7:01pm #5

Ah, you need to call this after the tracker has had a chance to update all the scene objects. Either use the LateUpdate method, or the OnTrackablesUpdated callback of the ITrackerEventHandler interface. See the ImageTargets sample for a sample script that implements this interface (Scripts/TrackerEventHandler).

- Kim

Re: Face Me

February 14, 2012 - 4:56am #4
ksiva wrote:

You should be able to use the camera's transform for this. Something like this:

myModel.transform.LookAt(Camera.main.transform);

Does that work?

- Kim

Hii,

This does work but makes the object flicker a lot.

Any tips on how i could avoid that?
Sriram

Re: Face Me

February 14, 2012 - 4:24am #3
ksiva wrote:

You should be able to use the camera's transform for this. Something like this:

myModel.transform.LookAt(Camera.main.transform);

Does that work?

- Kim

Hii,

This doesnt seem to work for some reason. Any ideas why? For a simple test i tried the ookat function on the teapot provided in the sample scene. Doesn't seem to do anything

Any clues on this would be helpful

Re: Face Me

October 10, 2011 - 8:29pm #2

You should be able to use the camera's transform for this. Something like this:

myModel.transform.LookAt(Camera.main.transform);

Does that work?

- Kim

Log in or register to post comments