fridays18 wrote: ↑Fri Feb 03, 2023 4:35 pm
My next question is how would I go about testing multiple clients connecting? I was able to give the client its own player which will be printed to the screen in main(it updates,draws and moves, through client) but when I made a second project identical to the current one and tried to run it I get this error
NoobHub: Attempt to publish without valid subscription (bad socket)
Noobhub: attempt to reconnect...
Noobhub connection error: connection refused
Problems with server..?
The error is quite descriptive I don't see what added, but here is a more complete and commented version.
In this example the client will send our info to all other players entering a game via the `client:enter` method and we will receive their info over time. This is not the best technique, what would be ideal would be to do something like a waiting list or a lobby that would allow you to join the game only when you have received all the information from the players present (at least in the area of spawn).
Then the client puts our position in the `client.world` table and we will have to update our position in this table, we will send our position contained in this table and receive that of the others. Of course this can be optimized this is only an example of a function. The ideal here again would be to calculate the difference between the old position and the new one received from another player in order to create a more natural movement, because the server is not refreshed as many times as the number of images to be our screen and in addition the latency time (ping) can be high for another player, all this will create jerky movements with the example I give you, hence the idea of calculating a delta of the positions and doing them move little by little. A good system like this can take a long time to set up, so focus on the essentials first.
With all this you should understand. Otherwise, regardless of the library used, it will be roughly the same principles, so to understand how to implement these techniques, you must already have plenty of Youtube tutorials on Unity or other that you can readapt.
Here is this new example, launch the server, launch the demo twice and contemplate the magic of multi