- Sort Posts
- 13 replies
- Last post
Multiple Trackables, one Image Target?
Multiple Trackables, one Image Target?
I had the same issue and I solved it with this:
https://developer.vuforia.com/forum/faq/unity-how-do-i-get-list-active-trackables
You basically have only one ImageTarget, then you get the trackables detected by the camera and then instantiate any object you want as a child of your ImageTarget
Hope it helps :)
Re: Multiple Trackables, one Image Target?
I think that you'll be OK running scripts on 20 ImageTarget instances. The event handler registers a callback to receive tracking state change notifications. It's not polling this w/ Update. And keep in mind that there is some cost to destroying and re-instantiating objects as well.
IMO the limiting factor is going to be how many targets you can track and render for simultaneously.
Here's a doc on optimizations for mobile devices running the Unity Player..
http://unity3d.com/support/documentation/Manual/iphone-Optimizing-Scripts.html
Thanks for the clarification. I have tested on over 20 ImageTarget. The framerate is OK since I only have one object to track and render at once.
Re: Multiple Trackables, one Image Target?
I think that you'll be OK running scripts on 20 ImageTarget instances. The event handler registers a callback to receive tracking state change notifications. It's not polling this w/ Update. And keep in mind that there is some cost to destroying and re-instantiating objects as well.
IMO the limiting factor is going to be how many targets you can track and render for simultaneously.
Here's a doc on optimizations for mobile devices running the Unity Player..
http://unity3d.com/support/documentation/Manual/iphone-Optimizing-Scripts.html
Re: Multiple Trackables, one Image Target?
@DavidBeard, I'm not worrying about the number of the dynamically initiated objects in the scene, but is it performance wise to have many ImageTargets script functioning at the same time? When a ImageTarget is detected and attached with actual content, do you think it's necessary to destroy all other ImageTargets?
@pushxtonotdie, I use the same method. I just reparenting "AssetToDisplay" when the OnTrackableFound method in DefaultTrackableEventHandler script is triggered for the first time.
And "AssetToDisplay" doesn't need to be initiated at runtime. They can be a group of large objects that exist in the scene. Just disable all child renderers to make those objects invisible from the beginning. When ImageTarget is detected and they are parented to that ImageTarget, DefaultTrackableEventHandler script will call to activate those renderers.
Re: Multiple Trackables, one Image Target?
Just thought I'd check in. The current technique I'm using is to dynamically reparent the GameObject in a copy of the DefaultTrackableEventHandler. I've created a public var called 'AssetToDisplay' and designers map the instantiated GameObject to this var, so that GameObject A maps to Image Targets BCD and GameObject W can map to XYZ and the designer can control this functionality without issue. This dynamic reparenting occurs like so:
AssetToDisplay.transform.parent = this.gameObject.transform; // [CH] Attach the assets to our parent.
I then loop through the children and start animations, sounds, etc.
This works pretty well but this may not scale to scenes with large numbers of targets and models. This method expects GameObjects to be instantiated at startup. A better approach may be to do as mentioned: instantiate a prefab, but we do not have a lot of content so this is not a big issue for us.
Re: Multiple Trackables, one Image Target?
Dynamic instantiation of objects is a commonly used technique in game development - e.g. for spawning characters, etc.. In and of itself, there is not a significant performance penalty. But you should do some testing. Your app's performance will be affected by the rendering complexity of the aggregate collection of objects that your are generating (i.e. up to 20 ).
here's an example of how to accomplish this using Prefabs..
http://unity3d.com/support/documentation/Manual/Instantiating%20Prefabs
Re: Multiple Trackables, one Image Target?
You're going to have to use multiple ImageTargets for this. You can use transform.parent to handle the parent assignment. And you can simply customize Default Trackable Event Handler if you like. But if you want the object to appear on multiple targets simultaneously, you'll have to clone it.
If I have more than 20 trackables in the scene for a single ImageTarget, will the method destroy the performance?
Re: Multiple Trackables, one Image Target?
Re: Multiple Trackables, one Image Target?
You're going to have to use multiple ImageTargets for this. You can use transform.parent to handle the parent assignment. And you can simply customize Default Trackable Event Handler if you like. But if you want the object to appear on multiple targets simultaneously, you'll have to clone it.
Re: Multiple Trackables, one Image Target?
Thanks for replying so quickly. I am not attempting to create a Multiple Target. I have three different images, for example, a horse, a bear, and a dog, and when the image is tracked, I have one object that I would like to appear regardless of whether it is a horse, bear, or dog. I would prefer not to have to create three separate image targets and three copies of the object to display.
I have thought about creating my own TrackableEventHandler that would dynamically parent the game objects to the correct Image Target if I have to. I'm assuming this is possible in Unity, but I'm a noob to both unity and vuforia.
Thanks,
C
I tried this but I don't know what to do next?
After detecting the trackable, how do you track it?