This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
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 (3,164 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 (6,942 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 Frequently asked questions and 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 [email protected] with your username.