Currently I have 2 cameras, one for viewing the 3D objects (Perspective), and the other camera to view 2D objects (Orthographic).
(Also, the view of the camera never intercepts each other.)

I am trying to display a 2D object based on the position of a 3D object, like so: Image of what I am trying to achieve

What I have is the respective 2D and 3D Camera, as well as the Vector3 position of the 3D GameObject.

What I have tried:

public Vector2 Convert3DPositionTo2DPosition(Camera camera3D, Vector3 position3D, Camera camera2D) {
    var tempPos = camera3D.WorldToViewportPoint(position3D);

    return camera2D.ViewportToWorldPoint(tempPos);

The only problem is that the returned position is not completely aligned with the 3D position.
Which results in this kind of results: Image of expected and actual result

Also, I have made sure that both the 3D and 2D object have their pivot point are set correctly in the center, but it still does not work as intended.

(I am currently using Unity 2019.1.14f1)


2 Answers 2


First use the WorldToScreenPoint method of the 3d camera to convert the position of the 3d object to screen coordinates:

Vector3 screenPosition = camera3D.WorldToScreenPoint(3dPosition);

Then use the corresponding method ScreenToWorldPoint of the 2d camera to find the point in the 2d world that corresponds to this screen position:

Vector3 2dPositon = camera2D.ScreenToWorldPoint(screenPosition);

When you still experience an offset, keep in mind that the transform.position of a gameObject does not necessarily correspond to what looks like the center of its visual representation. There are several circumstances which can lead to an object appearing at a different location than its transform. So if you still encounter problems like that, try reproducing them with simple primitives first to ensure that it's not a problem like misaligned 3d models, sprite pivots, child-objects with local position, etc.

Relevant documentation:

https://docs.unity3d.com/ScriptReference/Camera.ScreenToWorldPoint.html https://docs.unity3d.com/ScriptReference/Camera.WorldToScreenPoint.html


Instead of ViewportToWorldPoint use WorldToScreenPoint


Oh yeah, and call the function on your 2D camera :D

  • 2
    \$\begingroup\$ Can you explain why going via screen coordinates would have a different result than going via viewport coordinates? \$\endgroup\$
    – DMGregory
    Commented Aug 27, 2019 at 13:52
  • \$\begingroup\$ Unfortunately it did not work; The position is now way off from expected. Could you show the final result of the code, in case I missed out on anything. (P.S: would also be nice if you gave explanations like what DMGregory mentioned) \$\endgroup\$
    – Kaynnc
    Commented Aug 28, 2019 at 1:25
  • 1
    \$\begingroup\$ Looking again at your "Convert3DPositionTo2DPosition" function i notice you are converting your 3D position to a viewport position(on the 3D camera), then converting that position to the world position (on the 2D camera). What i wanted to say is that you don't need to do those 2 things, you only need to take the 3D position and do WorldToViewport on the 2D Camera public Vector2 Convert3DPositionTo2DPosition(Camera camera3D, Vector3 position3D, Camera camera2D) { return camera2D.WorldToViewportPoint(position3D); } \$\endgroup\$ Commented Aug 28, 2019 at 8:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .