Codeaddictx Posted December 9, 2016 Share Posted December 9, 2016 I am working on a multiplayer space shooter game. This works fine, but when the players are on different screens, their respective positions differ from each other in few pixels. How do I ensure the objects align across players/screens. Quote Link to comment Share on other sites More sharing options...
rgk Posted December 9, 2016 Share Posted December 9, 2016 Sync the x,y data along all clients as a backup to proper velocity misalignment. Quote Link to comment Share on other sites More sharing options...
Codeaddictx Posted December 10, 2016 Author Share Posted December 10, 2016 Thats exactly what I am doing. There is a central login point where coordinates are emitted to all clients. But some funny reasons I can't explain they won't just align. A simple test was to move one of the players directly over the other and left it there. It appears so on the first screen, but on the second, it was few pixels away from it. Quote Link to comment Share on other sites More sharing options...
digitspro Posted December 10, 2016 Share Posted December 10, 2016 41 minutes ago, Codeaddictx said: Thats exactly what I am doing. There is a central login point where coordinates are emitted to all clients. But some funny reasons I can't explain they won't just align. A simple test was to move one of the players directly over the other and left it there. It appears so on the first screen, but on the second, it was few pixels away from it. hey man. I'm soon going to start diving into multiplayer implementation like you. I have zero experience in that. I think you need to double check few things: 1) How you are reading the positions: position property, getAbsolutePosition(), scene.pick() data, window mouse event etc 2) When you are transmitting the data and whether the last coordinates you expect did really get received by the other client, and that they are really the last 3) How you are setting the positions: position property, etc. I do not have much information, nonetheless this is general guideline of what I would investigate on. I'm thinking, it would be useful to mock the events received from the server, like put them in a file and have that file be read line by line. Then I would be able to test the receiving client in isolation... UPDATE: just a little more clarification: Clearly, using coordinates reported by objects of the game engine is the right thing to do, because that's what's expected to remain consistent, unlike screen resolution, render width or mouse location on window. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.