I’ve got a perspective camera with an orthographic camera overlayed which contains dice.
I’m trying to dynamically animate dice in the perspective camera and have them fly to the positions of their orthographic counterparts. When I do this, the animated dice on the perspective layer end up in positions that don’t line up (outlined in green in my attached image). I assume this is due to the difference in perspective.
Is there a way to find the positions that visually line up with the orthographic camera’s positions?
Thanks for the help. I know they’ll never line up perfectly, I just need them to share the same center position so I can make a swap.
I’ve tried some combination of Camera.ScreenToWorldPoint but I’m missing something in my understanding. Would I use the perspective camera or the orthographic camera to calculate this position? Where am I getting the position value that should feed this function? The Rects on the orthographic view dice?
You would use the perspective camera and you’d feed it the 2D center of the orthographic view dice rectangles along with a world space distance from the camera as the z coordinate (value between perspectiveCamera.nearPlane and perspectiveCamera.farPlane). The smaller the value, the closer/bigger the 3d cube will be.
This will basically calculate a world position along the ray that originates from your perspective camera through the given pixel.