TechAssembly / ruven

Game for the Github Game Off 2018 - Themed HYBRID!
7 stars 4 forks source link

Player should send his initial location to the server before moving #21

Open gioragutt opened 5 years ago

gioragutt commented 5 years ago

Currently, due to how I prevent the client from spamming the server with data even if the player doesn't move, when the game starts, the player's position is 0,0,0 until he moves.

This is done in Assets/Scripts/Game/ColyseusLocalPlayer.cs. A simple boolean flag of wasSentAlready or something like that would suffice.

In order to test this:

  1. Open two clients
  2. Join the lobby
  3. Start the game
  4. One client should move
  5. That client should see the second client without him moving (and in turn sending his position).
gioragutt commented 5 years ago

Also, a possible fix would also be using

    void Start()
    {
        game.OnPlayerMove(transform);
    }

in the script, instead of the boolean flag.