Jump to content

Position of object in camera's coordinates in Unity3d.


Netvr

Recommended Posts

Request: Would you please change a privacy settings for OnChangeEyeCallback listeners to public in WaveVR_CanvasEye class. Otherwise I couldn't see any normal way to get left and right eye's cameras.

A goal is to get a position of object in camera's coordinates and to put there a canvas with text.

Link to comment
Share on other sites

Anyway this instances is should be getting when the camera is changing from left to right (method WaveVR_CanvasEye.changeEye() is runing)

 

I try to get position of object on screen by this part of script, and result is not correct.

void LateUpdate()
{

 Camera lefteyeCamera = WaveVR_Render.Instance.lefteye.transform.GetComponent<Camera>();

Vector3 pos = lefteyeCamera.WorldToScreenPoint(targetPosition)  

}

 

Link to comment
Share on other sites

Since the camera position changes over time, you could listen WaveVR_Utils.Event.AFTER_NEW_POSES to correct the position.

 

void Start () {

        WaveVR_Utils.Event.Listen(WaveVR_Utils.Event.AFTER_NEW_POSES, OnAfterNewPoses);

    }

 

    void OnAfterNewPoses(params object[] args)

    {

        Camera lefteyeCamera = WaveVR_Render.Instance.lefteye.transform.GetComponent<Camera>();

        Vector3 pos = lefteyeCamera.WorldToScreenPoint(transform.position);

    }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...