Jump to content
Happy Holidays! Limited Staff Responses: 1/20 - 1/31 ×

Position of object in camera's coordinates in Unity3d.


Netvr
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...