- Home /
ViewportToWorldPoint with multiple cameras
Hi,
I have setup two cameras and scripted a small item HUD for both. I use ViewportToWorldPoint() to set the items relative in the camera frustum.
var mineNew = Instantiate (mineItem, thisCamera.ViewportToWorldPoint(itemPosition[pointer]), Quaternion.identity);
mineNew.transform.parent = thisCamera.transform;
For Player1 is works as I wanted it. But for Player2 is doesn't work. The objects are still instanciated in the Player1 interface.
I have setup the layers for camera1 and camera2 and also adjusted the culling properties.
Any help? Thank you in advance!
0tacun
setup HUDcameras with different layers.
objects in those HUDcameras should also share those layers which they belong.
Don't forget to adjust the viewport rects of both HUDcameras to the same values as the normal cameras.
In the HUDcameras set the culling to either HUDcamera1 or HUDcamera2 layer.
the ViewportToWorldPoint() function worked for me.
hint: never use OnGUI :D only for mainmenu.
Your answer
Follow this Question
Related Questions
How to make a split screen in HDRP ? 1 Answer
ViewportToWorldPoint relative to camera angle 2 Answers
Code behind 'Camera.ViewportPointToRay'? 2 Answers
Having Issues with Camera Viewport Rect 0 Answers
Viewport to World Coordinates 2 Answers