Log in or register to post comments

User Defined Target Not Appearing in Game

July 21, 2014 - 11:25pm #1

Hey there!

I am trying to write a simple game that allows the user to create a user-defined target at the start. 

So far I'm having trouble getting user defined targets to function as intended. When I play my game, my User Defined Target appears to be tracked in the Console and Scene window, but I don't see anything happen in the Game window. 

I followed this guide to get my UserDefinedTargetBuilder to draw a GUI button to the screen, and to create and track a clone of an ImageTarget object placed in my scene when the button is pressed: https://developer.vuforia.com/forum/faq/unity-how-do-i-create-simple-udt-app

The camera appears to recognize the UserDefinedTarget clone properly, it just doesn't render its children in the Game preview window.

When the user defined target goes out of screen, I see the following message: 

Trackable UserTarget lost
UnityEngine.Debug:Log(Object)
DefaultTrackableEventHandler:OnTrackingLost() (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:105)
DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status) (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:56)
TrackableBehaviour:OnTrackerUpdate(Status)
DataSetTrackableBehaviour:OnTrackerUpdate(Status)
When the user defined target comes back onto the screen, I get this message: 
 
Trackable UserTarget found
UnityEngine.Debug:Log(Object)
DefaultTrackableEventHandler:OnTrackingFound() (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:84)
DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status) (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:52)
TrackableBehaviour:RegisterTrackableEventHandler(ITrackableEventHandler)
DefaultTrackableEventHandler:Start() (at Assets/Qualcomm Augmented Reality/Scripts/DefaultTrackableEventHandler.cs:30)
Furthermore, when I double-click on the actor in the Hierarchy list while playing, I can locate it in the Scene window. I can observe the camera object properly moving around it as it's tracked. The camera's location definitely appears to correlate properly to my webcam's relative location to the UserDefinedTarget. I just simply don't see any of this reflected in the Game window. 
 
When I create a copy of my scene and delete all the User Defined Target related object, and replace them with an ImageTarget object set to track one of my predefined targets, it tracks just fine and I can play my game properly. 
 
Does anyone have any insight as to what I may be doing wrong? I can post samples of my code, and screenshots if that would help. However, my code is identical to the code from the tutorial I linked above.
 
One additional note is that I have some NGui stuff in my scene, but it didn't appear to interfere with the Predefined image target version of my scene in any way. 
 
Any help would be greatly appreciate! Thank you!
 

 

User Defined Target Not Appearing in Game

February 23, 2015 - 10:22pm #4

A simple game works very well with user defined target. I am a fan of gaming and inspired to development, so would like to have more of the updations.

 

 

acheter the division

 

 

 

User Defined Target Not Appearing in Game

July 22, 2014 - 10:32pm #3

Thank you for your response dm3d.

Unfortunately this doesn't seem to solve the problem. I've ensured that my NGUI camera has a higher depth than the AR Camera.

Like I said before, when I switch from UserDefined back to a Predefined target, it renders properly. This makes me think it may have something to do with the way I'm setting up the user-defined target. 

Here is the script I'm using on my UserDefinedTargetBuilder to set up my target: 

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class SimpleUDTHandler : MonoBehaviour, IUserDefinedTargetEventHandler {
	
	private UserDefinedTargetBuildingBehaviour mTargetBuildingBehaviour;
	private ImageTracker mImageTracker;
	private DataSet mBuiltDataSet;
	
	private bool mUdtInitialized = false;
	private ImageTargetBuilder.FrameQuality mFrameQuality = ImageTargetBuilder.FrameQuality.FRAME_QUALITY_NONE;
	
	public ImageTargetBehaviour ImageTargetTemplate;
	
	void Start() {
		mTargetBuildingBehaviour = GetComponent<UserDefinedTargetBuildingBehaviour>();
		if (mTargetBuildingBehaviour) {
			mTargetBuildingBehaviour.RegisterEventHandler(this);
		}
	}

	public void OnInitialized() {
		// look up the ImageTracker once and store a reference
		mImageTracker = TrackerManager.Instance.GetTracker<ImageTracker>();
		
		if (mImageTracker != null) {
			// create a new dataset
			mBuiltDataSet = mImageTracker.CreateDataSet();
			mImageTracker.ActivateDataSet(mBuiltDataSet);
			
			// remember that the component has been initialized
			mUdtInitialized = true;
		}
	}

	public void OnFrameQualityChanged(ImageTargetBuilder.FrameQuality frameQuality) {
		mFrameQuality = frameQuality;
	}

	public void OnNewTrackableSource(TrackableSource trackableSource) {
		// deactivates the dataset first
		mImageTracker.DeactivateDataSet(mBuiltDataSet);
		
		// Destroy the oldest target if the dataset is full
		if (mBuiltDataSet.HasReachedTrackableLimit()) {
			IEnumerable<Trackable> trackables = mBuiltDataSet.GetTrackables();
			Trackable oldest = null;
			foreach (Trackable trackable in trackables)
				if (oldest == null || trackable.ID < oldest.ID)
					oldest = trackable;
			
			if (oldest != null) {
				mBuiltDataSet.Destroy(oldest, true);
			}
		}
		
		// get predefined trackable (template) and instantiate it
		ImageTargetBehaviour imageTargetCopy = (ImageTargetBehaviour)Instantiate(ImageTargetTemplate);
		
		// add the trackable to the data set and activate it
		mBuiltDataSet.CreateTrackable(trackableSource, imageTargetCopy.gameObject);
		
		// Re-activate the dataset
		mImageTracker.ActivateDataSet(mBuiltDataSet);
	}

	void OnGUI() {
		if (!mUdtInitialized) return;
		
		// If Frame Quality is medium / high => show Button to build target
		if (mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_HIGH ||
		    mFrameQuality == ImageTargetBuilder.FrameQuality.FRAME_QUALITY_MEDIUM) {
			if (GUI.Button(new Rect(Screen.width/2 - 100, Screen.height - 100, 200, 90), "Build New Target")) {
				BuildNewTarget();
			}
		}
	}

	private void BuildNewTarget() {
		string newTargetName = "UserTarget";
		mTargetBuildingBehaviour.BuildNewTarget(newTargetName, ImageTargetTemplate.GetSize().x);
	}

}

Attached is a screenshot showing the Inspector setup on my UserDefinedTargetBuilder that the above script is attached to.

AttachmentSize
Image icon userdefinedSetup_01.jpg193.96 KB

User Defined Target Not Appearing in Game

July 22, 2014 - 7:36pm #2

In this related thread, several users were able to get things working with NGUI by adjusting some of the camera depth parameters:

https://developer.vuforia.com/forum/issues-and-bugs/ngui-vuforia

 

Log in or register to post comments