Log in or register to post comments

Custom Trackable Event Handler

March 31, 2019 - 11:37pm #1

Hello, I am using Unity 2018.3.5 to develop for the HoloLens and I am using Image Targets so show some Objects to the user.

Since I need to add custom behaviour to the detection-progress, I created my own TrackableEventHandler-Script as a copy of the DefaultTrackableEventHandler-Script (as suggested in this post: https://developer.vuforia.com/forum/hololens/modify-ontrackingfound-ontrackinglost-behaviours?sort=2)

The only thing I added to the Handler is a check at the beginning of the OnTrackableStateChanged-Method if the current user position is close enough to a certain, static position. This calculation works, I logged it and the results are correct. The OnTrackableStateChanged-Method should return if the user is not close enough. But when I deploy to the HoloLens, it does not work.

All Objects, which are children of my Image Targets, are shown before I found a target and when I find a target they are placed, regardless if the position check returns true. 

I removed the default component in the inspector of the target-object and added my custom handler, but it still does not work!

Please help me find my mistake!

Custom Trackable Event Handler

April 1, 2019 - 6:50am #3

Thank you, that fixed my problem. It looks like it works as I wanted it too! :)

But I'm a bit unsure about your remark:

Quote:

a distance check will give you a valid value, just not one you're expecting, most likely

What do you mean by that?

 

Custom Trackable Event Handler

April 1, 2019 - 4:48am #2

It sounds like you'd be better off checking per frame if the distance between target and camera are below the threshold, provided the target is being tracked (!). Check the target's CurrentStatus to make sure it's actually tracked. https://library.vuforia.com/content/vuforia-library/en/reference/unity/classVuforia_1_1TrackableBehaviour.html#a767982f8ad2bca1cf7c7dc3694513eca

By default, the eventhandler only disables the target children's renderers. They're still all active and a distance check will give you a valid value, just not one you're expecting, most likely.

See if that helps.

Log in or register to post comments