c# - Unity3D Vuforia Camera Position in Real World Unit -


i using vuforia , unity3d develop application. this, need camera position (x,y,z) in real world unit image target while tracking image mobile phone. wondering if possible such position information in vuforia . if yes, sample code highly appreciated.

try this.

public class exampleclass : monobehaviour { public transform target; camera camera;  void start() {     camera = getcomponent<camera>(); }  void update() {     vector3 screenpos = camera.worldtoscreenpoint(target.position);     debug.log("target " + screenpos.x + " pixels left"); } } 

what transforms position world space screen space.

screenspace defined in pixels. bottom-left of screen (0,0); right-top (pixelwidth,pixelheight). z position in world units camera.

may not want starting point.

edit: returns world space not local space should want

public class exampleclass : monobehaviour { public gameobject someobject; public vector3 theposition;  void start() {     // instantiate object right of current object     theposition = transform.transformpoint(vector3.right * 2);     instantiate(someobject, theposition, someobject.transform.rotation); } } 

note returned position affected scale. use transform.transformdirection if dealing direction vectors. can perform opposite conversion, world local space using transform.inversetransformpoint.