What are the settings I need to do to actually setup so I can walk around an object and look at it. Tried various settings but right now the hololens only tracks the rotation of the head and not the spatial position. Which means that if I move around in the room it wont affect the camera in the game.
Ive tried the AR camera with both World Center Mode as DEVICE_TRACKER and CAMERA. Both seem to give the wrong result.
Do I need to manually move the camera from reading the device? Don’t think its how they solved this
In player settins I have spatialPerception selected aswell.
I am using Unity2017.2.0b11 with vuforia.
Any help/advice or link to a topic similar would be appreciated!
That won’t help much as I’m a beginner too, but regarding the first question of your post, and according to my tests, the camera position is changed when you move around with your hololens on your head. It’s working like this on all the tutorial I’ve. But maybe your problem is related with binding vuforia camera and hololens camera. I didn’t try integrating vuforia to hololens yet, so I can’t help too much.
Hmm I think they changed that with the hololenscamera and the vuforia camera. Since the script doesnt longer take a camera as input (I watched the other tutorials but they seemed outdated).
But maybe you are right and I somehow haven’t created a hololens camera, just don’t know how to input this to the vuforia system. I can see objects and image track them, its only the position from the hololens that seems off.
Can you link to the tutorial you was using? I maybe can look throught that and see if I find some answers there.
Tried now to just load a cube without vuforia and build to the hololens, that seems to work with the positional when I attached “TrackedPoseDriver” to the camera. Tried the same with vuforia, this did not work. think the vuforia renders this different. Thinking of maybe switching to pure unity and image detect some other way… According to the demos ive seen of vuforia I dont know if they have solved this, they kindof require the image to always be present.
So I’m using vuforia and hololens. What I’m doing is using the Vuforia image to spawn the object in the correct spot in the world and then using a “keyword” like “lock” and “restart” to turn on/off the vuforia aspects of the scene and add a world anchor to the object so I can then walk around the object here is some example code of how I’m doing it. Make sure you are using Vuforia and HoloToolkit namespaces for this code to work.
EDIT: The “found” bool on the DefaultTrackableEventHandler is a bool that I made to trigger state changes of the Image tracker I use it and a private bool to trigger the switch events in the update like this…
private void Update()
{
if(Found && !Showing)
{
OnTrackingFound();
Showing = true;
}
else if(!Found && Showing)
{
OnTrackingLost();
Showing = false;
}
}
public void OnTrackableStateChanged(
TrackableBehaviour.Status previousStatus,
TrackableBehaviour.Status newStatus)
{
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)
{
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
Found = true;
}
else if (previousStatus == TrackableBehaviour.Status.TRACKED &&
newStatus == TrackableBehaviour.Status.NOT_FOUND)
{
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");
Found = false;
}
else
{
// For combo of previousStatus=UNKNOWN + newStatus=UNKNOWN|NOT_FOUND
// Vuforia is starting, but tracking has not been lost or found yet
// Call OnTrackingLost() to hide the augmentations
Found = false;
}
}
Another thing to mention about Vuforia and hololens is the size of the printed marker and the size of the tracked image object in the scene directly correlate with each other. For example if you have a 4 inch printed marker make sure your image object in the scene is set to a scale of 0.1016. Because unity units equal a meter and 4 inches = 0.1016 meters. If you don’t have the scale the same as the real world object the hologram will most likely be off center or wrong sized in the view of the hololens. Hope this helps.
The problem for me was like joshua suggested that I had the wrong scale on the vuforia objects (was preset to 50, now im using 0.2969768 which should be a A4 paper format.
My solution was to enable/disable the vuforia behaviour on the camera. Then enabling all the renderers in the imagetargets and use a TrackPoseDriver on the camera.
Also the conversion 4 inch to 0.1016 kindof worked, it did not feel so exact as I wanted it. But anyhow now I need to see if I can config that value.
Thanks for your suggestion, however, I follow your instructions but my virtual object after locking continues to follow me (front hololens). Can you help me handle it?
Vuforia has a feature called extended tracking that is meant to lock the child game object in place once the image target is detected. It is in the Advanced section when looking at the Image Target Behavior (Script) component. This should get you started on getting the behavior you are looking for.