user3337790
user3337790

Reputation: 152

RPC takes minutes to update | Unity + PUN2

I'm just about to release a game in Unity with PUN2 and having a major delay issue with RPC calls. I am updating a value every time a button is executed, this:

[PunRPC]
private void takeOnePropertyTotal()
{
    totalProperties -= 1;
}

On my side it executes immediately, but on the second and third connected computer it takes the:

totalProperties -= 1;

even MINUTES to execute, which is insane and ruins the logic of the game completely. The computers are connected in the same region even and even on the same internet connection.

Any idea why this is delayed so much?

Upvotes: 1

Views: 184

Answers (1)

user585968
user585968

Reputation:


This is a summary of my comments beneath the question


OP:

It's in the update and is controlled via a bool

[PunRPC] void Update()
{ 
    if (updateValidator == true) 
    {
        view.RPC("takeOnePropertyTotal", RpcTarget.All); 
    } 
} 

So you are piling up RPC calls at a rate of typically 60 times per second!

It's OK to put it in Update(), it kind of makes sense to do so, however you might want to put a guard statement in there like

if (doINeedToSendAnUpdate) {  DoRPCStuff(); doINeedToSendAnUpdate = false; } 

...to control how many are sent per second.

That or maybe send updates every 100 ms or whatever your game's tick rate might be by looking at deltaTime.

Upvotes: 1

Related Questions