DoubleDeez / MDFramework

A multiplayer C# game framework for Godot 3.4 Mono.
https://discord.gg/UH49eHK
MIT License
77 stars 13 forks source link

PredictiveSynchronizationExample is failing #47

Closed Beider closed 4 years ago

Beider commented 4 years ago

PredictiveSynchronizationExample is currently not working. A quick initial investigation leads me to believe something is going wrong during replication of members for the actor class. I did check the replicator and we are sending out Rset calls to the PredictiveActor but the variables are not being updated.

I think this is because the client recieves updates for some future game tick but since the game is paused we never get there. The solution is probably to put the replicator into a special state during initial synchronization so that game ticks are ignored during initial synchronization

The PredictiveActor implements the IMDSynchronizedNode interface. The implementation blocks synchronization until all of the networked member variables have been updated.

public bool IsSynchronizationComplete()
{
    if (Speed == 0f || Direction == Vector2.Zero)
    {
        // Fake that we are taking variable time to synch
        FinishSynchAt = OS.GetTicksMsec() + (uint)Random.RandiRange(500, 8000);
        return false;
    }

    if (OS.GetTicksMsec() < FinishSynchAt)
    {
        return false;
    }

    return true;
}
Beider commented 4 years ago

This is probably easier to do after the unification of #62