Log in or register to post comments

How to: Only load script when I trackable is viewed???

November 10, 2011 - 6:38am #1

Hello,

I'm using the Unity version of QCAR. Now I made a JS script that makes my script move up and rotate.

*******
private var currentAltitude : float = 0.00;
private var degree1 : float = 0.00;
var maxAltitude : float = 0.50;
var snelheid : float = 0.10;
var degrees : float = 30;

function Update (){
if (maxAltitude > currentAltitude)
{
currentAltitude = currentAltitude + snelheid;
transform.position.y += currentAltitude;
}

else
{
degree1 = degrees;
}

transform.RotateAround (Vector3.zero, Vector3.up, degree1 * Time.deltaTime);
}
*********

But I want this script to reload every time i view my trackable with my mobile camera. And ONLY when i view my trackable.

So my question is: Is there a code that makes sure my script only starts when it views a trackable?? (at the moment my animation is done before somebody really noticed it)

Re: How to: Only load script when I trackable is viewed???

November 11, 2011 - 12:38am #3

Thanks for the fast reaction.

I found the OnTrackingFound (). But I'm quite new to this, and I dont know how to intergrate my JS with the C# script. ( It even took me quite a while to create the JS that I have at the moment ). Can you help me out once more?

Gr Le4nder

Re: How to: Only load script when I trackable is viewed???

November 10, 2011 - 8:03pm #2

Take a look at the TrackableEventHandler that comes with the samples. It has an OnTrackingFound method that would be a good point to call your script. Note that you'll need to put your javascript file in a folder that is compiled before the C# scripts (e.g. the Plugins folder).

- Kim

Log in or register to post comments