Send RPC also to the sender itself

Hi,
Is there a way to send an RPC also to itself with photon cloud and PUN? For example when a player shoots with a weapon, a RPC should be send to the server and is then passed to all clients. As you would do it with a authorative setup, but without checking anything. I need this because I want to start actions like shooting at roughly the same time on all clients and not immediatly on the client who fires the rpc and then some time later on all other clients. Because then for example a projectile is on an other position on the client who fires it then on all other clients, which is a huge problem when the latency is high.
Thanks for your help :).

Comments

  • I guess you specifically need to know if you can delay the RPC by actually sending and receiving it for execution.
    We currently don't have that option.
    It could be added to PUN though. It's possible to send events to everyone and doing that, you only have to skip direct execution.
    Another way would be to buffer every RPC that should be locally executed by the current roundtrip time. That would give you an approximation, too.
    I read that gamers don't mind a delay between button press and action, provided that the delay is constant. If your game relies on timing, you might want to delay everything by the same time delta.
  • Hi Tobias,
    Yeah thats right. When for example someone casts a fireball and the latency is high, I don't want that on the screen of the player who fired the fireball it hits an other player, while on the screens of all other players it misses(for example because the player jumped before the "fireball casting" was executed on his computer). Or do you see an other way in doing that? However, your idea of delaying the RPC is nice, I will do that. But which roundtrip time should I use? Is PhotonNetwork.GetPing() * 2 okay? That gives me roughly the same value as if i do PhotonNetwork.time - info.timestamp on of the clients(I assume PhotonNetwork.GetPing() is in milliseconds?). It would also be great if a real RPC to everyone(whitout direct local execution) could be added to PUN :).

    EDIT: I tested a bit further. PhotonNetwork.getPing() * 2 is often much higher then the real PhotonNetwork.time - info.timestamp. So what should I use instead?
  • Hi,
    is PhotonNetwork.getPing() the same as PhotonNetwork.time - info.timestamp? Or is getPing() only to the server and the other from one client to an other? I've got an idea how to execute the instantation of projectiles at the same time. Would be great if someone could comment on it and correct me if there are "better" solutions. I want to make something like a delayTime, from which the time an RPC took to arrive is substracted. So I do something like this when a RPC arrives:

    [code2=csharp]private IEnumerator executeFireball(double deltaTime, PhotonMessageInfo info){
    if(deltaTime <= delayTime){
    yield return new WaitForSeconds((float)(delayTime - deltaTime));
    }

    //action is executed[/code2]

    So the one player who casts the fireball got to wait the full deltaTime(for example 0.25 seconds), while on the other clients the action is executed on delayTime - deltaTime(the time the RPC took to arrive on the client).
    I calculate the deltaTime like that: PhotonNetwork.time - info.timestamp
    However, there is one problem. When the deltaTime of one of the clients is higher then the delayTime, the game gets inaccurate again.
    So I thought to make the deltaTime the highest ping of all players in the room. However, which time of all players should I use? The PhotonNetwork.getPing() often differs much from PhotonNetwork.time - info.timestamp. And how can I get the highest ping of all players. I found this solution: viewtopic.php?f=17&t=1804&p=8410&hilit=ping#p8410
    but I don't want to mess around in the Photon network code, so is there a better solution?
  • PhotonNetwork.getPing() is different from PhotonNetwork.time - info.timestamp:

    The ping is a smoothed roundtrip time between client and server. It excludes as much "local lag" as possible, calculating the delays as soon as the packages arrive.
    The server timestamp of PhotonNetwork.time is based on this roundtrip time and a timestamp the server provides. It is never fully precise (due to changing network lag and imprecision with Environment.TickCount being used).
    You should be able to use the PhotonNetwork.time - info.timestamp value to accomodate for lag but keep in mind that the values are not fully precise.

    Maybe it makes more sense to base all timing on our Photon server timestamp. Per event you more or less know when it was fired. You can calculate how far your projectile should have moved since it was fired and skip that minor portion of the path.
    If you also add a general delay of 100ms before you execute any RPC, then you have 100ms for the RPC to travel. If it arrives later than 100ms on a remote client, this client just skips a bit of the path.
Sign In or Register to comment.