Hello,
I am learning Godot and I am trying to implement a 2D multiplayer tank shooter game. Bear in mind that i started this little game single player and i am adding the multiplayer functionality now.
The game currently is structured to have a standalone server that I run via command line, and then clients connect to it via a join button. This part works fine and player movements are perfectly synchronized too.
What I am struggling with at the moment is when the player shoots.

The project is hosted here: https://github.com/mrosati84/Bang24 if you want to have a look, i am working now in the multiplayer_fire branch.

This is what i have understood also talking with some friends. When the player shoots, the following happens:

  1. the player's game sends an RPC to a server function that informs the server that "i have shoot" (rpc_id(1, ...))
  2. the server receives this call, and instantiates the bullet
  3. the server finally appends the bullet to the scene, passing via a multiplayer spawner
  4. the bullet then lives its own life, by syncronizing its properties across peers

I have an autoloaded scene that contains only server stuff, where i have the "fire" method that the player calls via RPC.

The bullet's properties are synchronized via a synchronizer, and right now if i shoot, the projectile is correctly appended and propagated to the other peers, and it moves too.

However it seems there is no way to modify the starting position of the bullet, it always shoots from the initial point (where the spawn path is), even if i move my player. The code of course uses the player position to determine where to spawn the projectile, it works in single player, but not in multiplayer.

I will append some screenshots to let you know how my project is organised, thank you so much any help is super appreciated!

Matteo

The server

The main scene