0 votes

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.

Godot version 3.2.3
in Engine by (1,981 points)

1 Answer

0 votes

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
- verifydatareceived()
- synclocaldatawithreceiveddata()
- update
visualstorepresentreceiveddata()

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

by (3,026 points)

If you're wondering what kind of game it is, the game is a 3D shooter.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.