- Home /
Hololens camera Gaze and select by air tap
Hi there,
I'm developping an app on the hololens in which I need to select object by gazing at them and air taping ( just like the microsoft holograms app ).
For test purpose I've done 4 basic cubes that I can select and place by air taping, works great most of the time, but the main problem is that for no apparent reason, there is randomly one of the cubes that I can"t select.
It's never the same, and even if I delete it and create a new one, which is an exact copy of the others, then it will be another that wont be able to be selected. It seems like its totally random, it changes at each launch of the unity editor. And it's kind of annoying,
I'm using these :
Unity 2018.1.1 ( even with the previous version I had the same bug )
Hololens toolkit
Hololens camera prefab on unity
I use the following code
public void OnInputClicked(InputClickedEventData eventData) {
// If the hitted object by the gaze is the one that this is attached too then we can select it
if (gaze.HitObject == gameObject) {
if (!GazeMover.IsSelected) {
// We only want 1 selected object so we deselect all
foreach (var move in allMoveByGaze) {
move.DeSelect();
}
// We select this object
GazeMover.Select();
Debug.Log(gameObject);
}
else {
// We deselect the object
GazeMover.DeSelect();
}
}
}
On the debug log I see that the non moving object is being selected, but the corresponding boolean value of the script, telling that it is selected doesn't change.
The Select and DeSelect function are just these
public void Select() {
IsSelected = true;
}
public void DeSelect() {
IsSelected = false;
}
I tried with and without them, same behaviour ( as expected ) They are located in the other script that enables the movement if the object is selected.
So I'm asking why does this work randomly ?
And how to correct it ?
I've tried removing the loop that deselects all objects , but I doesn't change anything.
Thanks for reading :)
Your answer
![](https://koobas.hobune.stream/wayback/20220612163248im_/https://answers.unity.com/themes/thub/images/avi.jpg)