- Home /
World and Screen space Multiplayer[Touch Screens]
I have two touch monitors that I want to sync over a network. A user can drag an object by touching the screen. Whenever a user touches the screen, an icon appears there. I need to notify other users over the network when a user touches the screen. However, both users can be looking at different parts of the world. Meaning that if I'm not looking at the same location as another user, then I won't see when they are touching the screen.
I tried ScreentoWorldPoint values over the network and the receiving user transform it back to WorldtoScreenPoint. However, it only works if they are looking at the exact same location.
On one side calculate the world point that the user is clicking, on the other side convert that world point back to screen space and put the icon there
I tried that and it doesn't work like you think it might. Only if both clients have their camera in the exact location.
It works no matter where the cameras are, unless you implemented it incorrectly
It does work like I think it does, because I have done it that way before :)
Answer by meat5000 · Aug 23, 2013 at 01:13 AM
Converting WorldtoScreen space will calculate the world to YOUR screen and not the screen the touch was made on!
When you touch the screen you can find the distance to the game world underneath the touch with Raycast.
Feed the world position, touch ray direction vector and distance into intermediate storage variables. Pass these variables to the other device and use them to reverse calculate where the other screen is located. The actual screen touch position is not useful as, if you think of it, looking out of the world to the back of the screen, the screen would be massive.
Simply use the world position and the direction vector of the ray (reversed) from the other devices Screen to World touch to draw your line the same distance as the ray. Place your icon there.
Your line will assume the touch came from the centre of the other screen and the icon will move as the ray changes. Make it a Finger icon and you are set :P
Your answer
Follow this Question
Related Questions
Fitting GOs from world point to screen space UI. 1 Answer
Zoom in on tapped point in 3D space 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# change an object tag wit raycasthit. 2 Answers