- Home /
Problem with Camera.ScreenToWorldPoint() on 2D Multiplayer
In the game I made to test out the multiplayer part of unity I managed to get everything to work the way I wanted (yay) except that it only works on the host and all clients with the exact same resolution and window position. I assume the problem is, that there is only one camera in the scene, and the host sets its resolution. So when I use
Vector2 targetPosition = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
targetPosition = cam.ScreenToWorldPoint(targetPosition);
it translates the screen point as the client had the same resolution and window position as the host. Would it work, if I creat a new camera attached to each new player, or is there another way to correctly translate screen space to world space with only one camera? The camera is set to Camera.main on start (when the player connects to the multiplayer scene)
Local Coop or Peer to peer? Is this code running on the server only, or on each client?
The script is on the player, but it checks if its the local player before this part runs
Your answer
Follow this Question
Related Questions
2D terrain with pixel perfect and dynamic camera 0 Answers
Camera fix with resolution 0 Answers
How to handle camera rotation in a 2d multiplayer 0 Answers
Camera viewport should be square and pixel-perfect, regardless of player aspect ratio. 0 Answers
Orthographic Static 2D Background - IOS/Iphone 3,4 & 5 1 Answer