Point projection on orthogonal camera

Well, here’s the situation:

I have 3d objects on scene, rendered by perspective camera(mainCamera).
And I have orthographic camera, needed for drawing ui(uiCamera).

And now I need to draw my gui on specified point, taken from mainCamera. How to calculate projection of point from mainCamera to uiCamera?

This sounds very strange. Do you want to determine a screenspace position from a worldspace position to know where you have to display your gui camera? Or do you want a 3D-plane somewhere in the world which should display your gui camera content.

For the first case all you need is Camera.WorldToScreenPoint. Use it on the main camera to project a worldspace point into screen space. If you want to use it to set the viewport of the second camera Camera.WorldToViewportPoint might be handy as well.

In the second case is suggest to use a RenderTexture when you have Unity pro. When you don’t have Unity pro it gets really tricky and the result might don’t look nice. You should be familiar with matrices in this case :wink:

You just need to get the screen coordinates from mainCamera and use them to draw the GUI on the uiCamera. Something like the following:

GameObject hero;
GameObject herosHealthBar;    

Vector3 screenCoordinates = mainCamera.WorldToScreenPoint(hero.transofrm.position);
herosHealthBar.transform.position = uiCamera.ScreenToWorldPoint(screenCoordinates);

This should move herosHealthBar to lie on top of hero