0

My application using Unity And Vuforia. I want set position of 3D model of tracked found target to center Screen and AR Camera after track lost. I mean that I want to show lost Image target on center position.

Sopheak
  • 115
  • 2
  • 10
  • You should make sure to accept your other answers that helped you. You ignored many of these. http://stackoverflow.com/questions/36706706/how-to-set-background-image-texture-after-tracked-found-in-vuforia-imagetarget http://stackoverflow.com/questions/36686984/how-to-keep-tracked-image-target-model-object-after-tracking-lost http://stackoverflow.com/questions/36685553/how-to-keep-grid-view-scroll-position-after-fragment-pop-back-stack – Programmer Apr 22 '16 at 05:38

1 Answers1

0
   void centerGameObject(GameObject gameOBJToCenter, Camera cameraToCenterOBjectTo, float zOffset = 2.6f)
    {
        gameOBJToCenter.transform.position = cameraToCenterOBjectTo.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, cameraToCenterOBjectTo.nearClipPlane + zOffset));
    }

Then you can call it with

centerGameObject(gameOBJ, Camera.main);

The default zoffset(2.6f) should work but you can change it by supplying the third parameter.

centerGameObject(gameOBJ, Camera.main, 6f);
Programmer
  • 121,791
  • 22
  • 236
  • 328
  • @Sopheak I am assuming you also want your object to not disappear. In that case see my answer here on that topic: http://stackoverflow.com/questions/36686984/how-to-keep-tracked-image-target-model-object-after-tracking-lost/36687578#36687578 – bpgeck Apr 26 '16 at 01:18