Problem with character movement

Options
Hi,

We are developing a 2D Top-Down game. Our character is built with a rigidbody2D and is moved with root motion (for animations we are using Spine).

I' ll ty to sync movement and animations over the network. I write my own Animator component that interact with Spine Skeleton. After, following the structure of PhotonAnimatorView, I developed a PhotonMyAnimatorView component. It works exactly as PhotonAnimatorView (with synchronized parameters).

First time, I always called an RPC function when a parameter value was changed. But they change to often and RPCs are perform-less. So, I change my approach and now I'm using PhotomStreamQueue.

The problem is:

When I were using RPC (with Target = AllViaServer) the synchronization was perfect, with no delay. Now instead, I have a little delay between clients.

Is there a way to perform better and eliminate delay (something for simulate AllViaServer with PhotonStreamQueue)?

Thanks.
Andrea.

Comments

  • Tobias
    Options
    When you used AllViaServer, you (most likely) waited for the incoming values from the server, even for the local character. This makes the sync more accurate at the cost of some bandwidth.
    As the PhotonAnimatorView might send values quite often, we don't tell the server to send it back. The client has the values already. They get applied right away and this results in a difference.

    In most cases, this should be ok: Players don't sit next to each other and check how synched their characters are.

    I can't help with code right now, but in theory, you could delay all updates by one roundtrip time for the local player to get back in sync.
    You could also find the internal RaiseEvent call of PUN where it sends the updates. Make that use AllViaServer and skip the local update.

    If you have a 2D top-down game, I wonder if it would be OK to send input ("actions") and then animate all characters based on those, instead of syncing the whole animation tree?
  • erre
    Options
    Hi Tobias,

    thank you for your advices! You're right: players don't sit next to each other and check how synched their characters are. I'm just warried about feedback on actions (for example melee attack, on my client I see that I hit an enemy but on the master client I don't (because I will have some frames of delay)).

    I have no experience with Network game programming, so maybe it will not a real problem: I just would try to synchronize the character better as possibile! :smile:

    I can't do what you say at the end of your answer because our charcater control is a bit complex and we have a complex character hierarchy too.

    So, I hope this will not be a problem in the future for our game, but I suppose that if the connection is good, we will have no problem.

    But at least now I'm sure that my approach to synchronize the character isn't totally wrong.

    Thank you very much.
    Bye,
    Andrea.