Log in or register to post comments

AR/VR Sample - Moving the reticle

March 12, 2017 - 12:11pm #1

I am working on a project that is based on the AR/VR sample, so a lot of the scripts are the same as in the sample.

I want to move the reticle to the upper left corner of the camera, not to have it as it is now, right in the middle of the camera.

The reticle can be repositioned in the script Reticle.cs, and the Gazeray can be moved in GazeRay.cs. I first moved the Reticle to (-1, 0.6, 0) and the GazeRay to (-2.41, 1.4, 0) which is approximately the same position when used with the PC's webcam. But when I build to Android it does not work so good. 

1. Why can't I use the same vector for the positions of the Reticle and the GazeRay? Am I missing something?

2. Can it be done in a better way? When they are in the middle of the camera it works so good to activate triggers, when moved it doesn't work good at all.

I would highly appriciate all help, have been stuck on this issue for a while now :(

AR/VR Sample - Moving the reticle

March 14, 2017 - 8:22am #2

Managed to find one solution :D

In Reticle.cs, change;

this.transform.localPosition = Vector3.forward * bgDepth;

to;

this.transform.localPosition = new Vector3("wanted x-pos", "wanted y-pos", 1) * bgDepth;

The Gazeray's position needs to be the same. When the Gazeray's position is set it needs to be;

this.transform.localPosition = new Vector3("wanted x-pos", "wanted y-pos", 1) * bgDepth;

instead of the current piece of code that sets the localposition (don't remember what that code is exactly).

Therefore it also needs the following piece of code above it so it can use the variable bgDepth;

Camera cam = DigitalEyewearARController.Instance.PrimaryCamera ?? Camera.main;     BackgroundPlaneAbstractBehaviour bgPlane = cam.GetComponentInChildren<BackgroundPlaneAbstractBehaviour>();

float bgDepth = bgPlane.transform.localPosition.z;

Log in or register to post comments