Log in or register to post comments

adding multiple trackables in unity

March 31, 2012 - 11:38am #1

hello everyone
im working on a project using unity 3d that requires 30 trackables to be added in a single application. can anyone guide me how can it be done and what changes are required (both in unity and c# scripting )to make in the ImageTargets example.

adding multiple trackables in unity

November 29, 2012 - 4:41pm #23

i gort it working, yeah theres a slight delay when it loads, will try to load in bg like you mentioned.

thanks man

adding multiple trackables in unity

November 29, 2012 - 4:32pm #22

private void OnTrackingFound()

    {

        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();

 

        // Enable rendering:

        foreach (Renderer component in rendererComponents) {

            component.enabled = true;

        }

if (mTrackableBehaviour.TrackableName == "01_Trackable" && (Application.loadedLevelName != "Level_01")){

//Debug.Log(myGameObject.LevelLoaded1.Level01IsRunning);

//Debug.Log("Trackable 01 found");

Application.LoadLevel ("Level_01");

}

if (mTrackableBehaviour.TrackableName == "02_Trackable" && (Application.loadedLevelName != "Level_02")){

//Debug.Log("Trackable 02 found");

Application.LoadLevel ("Level_02");

}

 

        //Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

    }

 
 
This is causing errors, see PM.  This is urgent, thanks again
 
 

adding multiple trackables in unity

November 29, 2012 - 1:33pm #21

I've had a chance to look at your project, and it is working. The Unity player will pause when loading new scenes, which may be what you're seeing. See my PM for instructions on how to reduce this effect.

LoadLevelAsync

Loads the level asynchronously in the background.

LoadLevelAdditiveAsync

Loads the level additively and asynchronously in the background.

LoadLevelAdditive

What devices are you seeing crashes on?

If you want to avoid a scene loading pause entirely, you'll need to design your app as a single scene and handle any sequencing of the targets programmatically. 

adding multiple trackables in unity

November 29, 2012 - 10:24am #20

bump

adding multiple trackables in unity

November 29, 2012 - 10:24am #19

bump

adding multiple trackables in unity

November 29, 2012 - 10:24am #18

bump

adding multiple trackables in unity

November 28, 2012 - 6:45am #17

did you ever get this working?

adding multiple trackables in unity

November 28, 2012 - 6:15am #16

Ok, is tried creating a flag so that it only loads a level if its not found the level its on,

 

private void OnTrackingFound()

    {

        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();

 

        // Enable rendering:

        foreach (Renderer component in rendererComponents) {

            component.enabled = true;

        }

if (mTrackableBehaviour.TrackableName == "01_Trackable" && LevelLoaded1.Level01IsRunning != 1){

Debug.Log("Trackable 01 found");

Application.LoadLevel ("Level_01");

}

if (mTrackableBehaviour.TrackableName == "02_Trackable" && LevelLoaded2.Level02IsRunning != 1){

Debug.Log("Trackable 02 found");

Application.LoadLevel ("Level_02");

}

if (mTrackableBehaviour.TrackableName == "03_Trackable" && LevelLoaded3.Level03IsRunning != 1){

Debug.Log("Trackable 03 found");

Application.LoadLevel ("Level_03");

}

if (mTrackableBehaviour.TrackableName == "04_Trackable" && LevelLoaded4.Level04IsRunning != 1){

Debug.Log("Trackable 04 found");

Application.LoadLevel ("Level_04");

}

if (mTrackableBehaviour.TrackableName == "05_Trackable" && LevelLoaded5.Level05IsRunning != 1){

Debug.Log("Trackable 05 found");

Application.LoadLevel ("Level_05");

}

if (mTrackableBehaviour.TrackableName == "06_Trackable" && LevelLoaded6.Level06IsRunning != 1){

Debug.Log("Trackable 06 found");

Application.LoadLevel ("Level_06");

}

if (mTrackableBehaviour.TrackableName == "07_Trackable" && LevelLoaded7.Level07IsRunning != 1){

Debug.Log("Trackable 07 found");

//Application.LoadLevel ("Level_07");

}

if (mTrackableBehaviour.TrackableName == "08_Trackable" && LevelLoaded8.Level08IsRunning != 1){

Debug.Log("Trackable 08 found");

//Application.LoadLevel ("Level_08");

}

if (mTrackableBehaviour.TrackableName == "09_Trackable" && LevelLoaded9.Level09IsRunning != 1){

Debug.Log("Trackable 09 found");

//Application.LoadLevel ("Level_09");

}

if (mTrackableBehaviour.TrackableName == "10_Trackable" && LevelLoaded10.Level10IsRunning != 1){

Debug.Log("Trackable 10 found");

//Application.LoadLevel ("Level_10");

 

}

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

    }

 
 
And in each level there is a game object with its own unique JS script attached with the following:
 
static var Level01IsRunning = 1; 
static var Level02IsRunning = 0; 
static var Level03IsRunning = 0; 
static var Level04IsRunning = 0; 
static var Level05IsRunning = 0; 
static var Level06IsRunning = 0; 
static var Level07IsRunning = 0; 
static var Level08IsRunning = 0; 
static var Level09IsRunning = 0; 
static var Level10IsRunning = 0; 
 
function OnGUI () {
GUI.Box (Rect (0,0,200,50), "level1");
}
 
 
It builds without error but when i run the APK on my phone and pint to the different trackables its stays on level 1 so the folling type bits are never true:
 
if (mTrackableBehaviour.TrackableName == "02_Trackable" && LevelLoaded2.Level02IsRunning != 1){
 
 
Please help...
 
Oh ive also moved all my JS scripts into the plugins folder as mentioned on other posts, doesnt seem to help on this occasion.

adding multiple trackables in unity

November 28, 2012 - 4:54am #15

 its hammering the memory,

im gettin 1 frame every 2 seconds, it would appear to be constantly loading the same scene again and again,

It loads the first tracker, then a scan across to the next and it locks up, like its caught in a loop.

Is there a way to detect if different maybe? Its almost as if its constantly reloading.

 

#

 

 

 

thx man 

 

 

adding multiple trackables in unity

November 26, 2012 - 12:44pm #14

When i move the camera in the window over to another trackable it is supposed to trace / debug to say it has detected them, it doesnt.

 

adding multiple trackables in unity

November 26, 2012 - 12:37pm #13

I've just built and run your project and am not seeing any errors, and the targets are being detected. Make sure to add your scenes to the Scenes In Build within Build Settings. There were none added in the project you'd sent. 

adding multiple trackables in unity

November 26, 2012 - 11:52am #12

Hi David, thanks for getting back to me....

I have the scene set up and have opened the c# file named: DefaultTrackableEventHandler's 

I have changed the function as suggested to:

private void OnTrackingFound()

    {

        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();


        // Enable rendering:

        foreach (Renderer component in rendererComponents) {

            component.enabled = true;

        }

if (mTrackableBehaviour.TrackableName == "01_Trackable"){

Debug.Log("Trackable 01 found");

//Application.LoadLevel ("Level_01");

}

if (mTrackableBehaviour.TrackableName == "02_Trackable"){

Debug.Log("Trackable 02 found");

//Application.LoadLevel ("Level_02");

}

if (mTrackableBehaviour.TrackableName == "03_Trackable"){

Debug.Log("Trackable 03 found");

//Application.LoadLevel ("Level_03");

}

if (mTrackableBehaviour.TrackableName == "04_Trackable"){

Debug.Log("Trackable 04 found");

//Application.LoadLevel ("Level_04");

}

if (mTrackableBehaviour.TrackableName == "05_Trackable"){

Debug.Log("Trackable 05 found");

//Application.LoadLevel ("Level_05");

}

if (mTrackableBehaviour.TrackableName == "06_Trackable"){

Debug.Log("Trackable 06 found");

//Application.LoadLevel ("Level_06");

}

if (mTrackableBehaviour.TrackableName == "07_Trackable"){

Debug.Log("Trackable 07 found");

//Application.LoadLevel ("Level_07");

}

if (mTrackableBehaviour.TrackableName == "08_Trackable"){

Debug.Log("Trackable 08 found");

//Application.LoadLevel ("Level_08");

}

if (mTrackableBehaviour.TrackableName == "09_Trackable"){

Debug.Log("Trackable 09 found");

//Application.LoadLevel ("Level_09");

}

if (mTrackableBehaviour.TrackableName == "10_Trackable"){

Debug.Log("Trackable 10 found");

//Application.LoadLevel ("Level_10");

 

}

        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");

    }

 

 Ive commented out the code as im in debug, but when i pley play and move the camera around over the variuos trackables it does register.

 

The console spits out errors:

Trackable 02_Trackable found

UnityEngine.Debug:Log(Object)

DefaultTrackableEventHandler:OnTrackingFound() (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:113)

DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status) (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:49)

TrackableBehaviour:OnTrackerUpdate(Status) (at Assets/Qualcomm Augmented Reality/Scripts/TrackableBehaviour.cs:150)

QCARManager:UpdateTrackablesEditor() (at Assets/Qualcomm Augmented Reality/Scripts/QCARManager.cs:421)

QCARManager:UpdateTrackers() (at Assets/Qualcomm Augmented Reality/Scripts/QCARManager.cs:329)

QCARManager:Update(ScreenOrientation) (at Assets/Qualcomm Augmented Reality/Scripts/QCARManager.cs:223)

QCARBehaviour:Update() (at Assets/Qualcomm Augmented Reality/Scripts/QCARBehaviour.cs:274)


Ive PM'd you the test project for your perusal.

If you could help me out id be eternally grateful!

 


adding multiple trackables in unity

November 26, 2012 - 7:34am #11

What you'll need to do, is to generate a dataset from the TMS that contains all 10 trackables. You'll need to add this to the ARCamera of every scene that you're authoring. You'll also need to add each target to every scene, so that they are detectable and you can go from a given scene to any other.

To switch between scenes, add your scene navigation logic to the DefaultTrackableEventHandler's OnTrackingFound method. I'd recommend doing this in C#, otherwise you'll need to call a JS component.

adding multiple trackables in unity

November 22, 2012 - 4:46am #10

btw im using unity 3.5.6

and javascript - but im not the worlds greatest coder - so in lamens terms. woop

adding multiple trackables in unity

November 22, 2012 - 4:45am #9

Sorry to bump such an old thread guys....

im a noob and i want to create a scene that has 10 trackables stored in it,

when the camera points at one trackable it quickly loads that scene,

When it is pointed to another trackable it loads that one instead,

So all the 10 scenes are looking for all 10 trackers.

 

Also i dont have unity pro, any ideas of how i could elegantly get a pre loader every time it spots a tracker that isnt the one loading?

As far as im aware pre loaders are for unity pro only.

Re: adding multiple trackables in unity

April 4, 2012 - 2:56am #8

Thanks! :)

Re: adding multiple trackables in unity

April 3, 2012 - 8:17pm #7

You're welcome.

@Mary You can use multiple scenes, but the Unity Player only loads one scene at a time. So if you use multiple scenes, and want to use targets in a different scene, you'll need to load that scene using Application.LoadLevel.

Re: adding multiple trackables in unity

April 3, 2012 - 5:20am #6

lol, i figured it all out in the end. actually i was confusing dataset with something else :p
got it working fine and smooth :D
thanx alot David :)

Re: adding multiple trackables in unity

April 3, 2012 - 2:53am #5

Dear maryhary,
im doing all the work in a single scene.....

Re: adding multiple trackables in unity

April 3, 2012 - 2:51am #4

Dear Mr.David
i have created datasets for all 30 trackables, but the problem that im facing right now is that when i use the dataset in ARCamera, i have activated one dataset for a single imagetarget and checked the load dataset checkbox option in the inspector view of the ARCamera, now only that imagetarget is shown whose dataset i have activated, while the other imagetargets do not show when i move the camera towards their respective trackables :/
please help

Re: adding multiple trackables in unity

April 3, 2012 - 2:30am #3

Hello!

But do you then have to add all the image targets in one scene, or can they be in different scenes? I'm not getting the different scenes thing to work...

Thanks :)

Re: adding multiple trackables in unity

March 31, 2012 - 12:05pm #2

You'll simply need to create a dataset from within the TMS website that contains these Trackables, and then import this into your project. Then configure the Data Set Load Behaviour on the ARCamera to load and activate this dataset. Each ImageTarget that you use will need to be configured for a given trackable using the Image Target Behaviour panel in the inspector.

Is this what you are asking?

Log in or register to post comments