|Topic was automatically imported from the old Question2Answer platform.
I have a multiplayer game, and I need to determine who scored points and kill counts against other players. I’m mostly using projectile weapons in the game, so raytraces are rarely used, and the weapons shoot individual bullets towards other players.
Currently, the bullets carry the shooter’s name, and so, on collision with opponents, the player script checks the name on the bullet. On a successful kill, the killed player’s character script emits a signal that they have died, and passes the name of the previous player who shot them. This is complex, and I would like to simplify it.
Firstly when dealing with multiplayer or just any game in general one should have the code deal with all the interactions and the art/effects/visuals represent those changes. So mixing the two is a big debugging nightmare waiting to happen.
Keeping that in mind you’d want to have these functions in a singleton or your main scene
send_encoded_packet() #sends data between clients or to server
receive_encoded_packet() #what to do when data is received
if your connections are p2p have a Host randomly assigned that receives all the data
quality checks it then sends to all connected clients
if you want actual code snippets that’ll depend on the type of game you’re developing
If you’re wondering what kind of game it is, the game is a 3D shooter.
Ertain | 2021-01-18 08:45