As the title said, I am trying to make a multiplayer top down shooter, I get the gist of the client server model and java sockets, but I am unsure as exactly where to put them… What I mean is, a single player starts a server, then after every one links to it, what exactly should be sent to each player. Does every player only send their location to the server, location of any projectiles they fire, the ID of an enemy if they hit it? If someone has a link to a tutorial or something on the subject pls tell me. THX for ANY help!
Usually the players just send their input data (if they are going on X direction, if they are pressing SHOOT, etc.) and the server handles everything, from collision to movement of all players, to avoid hacking.
Imagine if the players have to send their own object data to the server: Since it would be in their own computers, they should be able to modify it’s memory address to change anything they want.
This usually results in players flying everywhere, shooting everywhere and people getting killed like it’s a drone attack.
makes sense… so say when someone presses the button to shoot, should that player send a series of varriables or IDs needed to create the object on the server, or create the object and send it to the server (is that possible?), I assume the former, so after the server has the object(s), does it send the data for ALL of those objects to every player, or just ones that have changed?
There are endless ways to achieve it.
In general you want to keep the server-side and the client-side datas sync’ed as much as possible. Both ways are possible, but you must take several factors, like bandwidth, into account. Sending an entire object might be harder and slower than sending just the variables that changed.
Instead of sending position updates constantly, you can predict motion with an equation.
Server updates every player client with current gametime, local objects and equation of motion (object starting position, equation plots where it will be). Can give an updated snapshot of this.
Every player client updates server with location, change of course and any actions of player… Also timestamp of when this happened.
Every player client uses object list and equation of motion to update what is on screen.
Maybe server decides whether someone has been hit or not and creates objects based on timestamp and action? Maybe this is handled on individual clients and confirmed by the server?
You can also cheat by updating generic source of particle effects, rather than each particle.
I’m sure theres probably an api or tutorial for this… Dont be afraid to read tutorial about how to network a 3d fps, as apart from the extra dimension, the problem is the same.