What type of RPC ?

Hi everybody !

I'm doing a 2d multiplayer game with photon and I need some advice..

I have I'm my room a monster , when a player enter in the "target detection collider " of my monster, the client send RPC to other to tell that he is the target .
But sometimes , if two people enter in the same time in the collider, the both are consider like a target .. so each client see the monster attack him ..

So I would like to know if there is a way to solve this problem ..:/

It's like a car game , in my case , 2 player can finished at the first place and I don't want that :/

Thanks if you can help me ! Have a good day :)

Comments

  • Andrebirnfeld
    edited November 2017
    Have a similar problem here... In a racing game.

    The problem is when player 1 entered in detection collider it's takes 100 ms for the other player receive this message. (let's consider both users have ping 50)

    So if the other player enter in detection collider in this interval between player 1 enter and he receive the message that player 1 entered, this problem will always occur.



    Let's try to think solutions together until someone expert have a better idea:

    Option 1) We could use "photon server", which is I think is a huge time of work and money spent (if you already paid PUN, like me). Because in Photon server the server handle the messages and delivery them to the players at same time. (I'm not sure about what I'm talking). The point is we need a server side handler service, maybe.

    Option 2) --someone please tell me there is an option 2---
  • Hey bro!

    Just find something helpful maybe... take a look here:

    http://forum.photonengine.com/discussion/10873/rpc-which-is-better-all-buffered-or-all-buffered-via-server#latest

    in the answer of Chris. Looks like exactly what we need... but I'm not sure, can you confirm that?
  • Thanks for your help !
    I find somethings but my english is not very good so i'm not sur of this explaination

    :Targets, Buffering and Order

    You can define which clients execute an RPC. To do that, use the values of PhotonTargets. Most commonly, you want All clients to call the RPC. Sometimes only Others.

    PhotonTargets has some values ending on Buffered. The server will remember those RPCs and when a new player joins, it gets the RPC, even though it happened earlier. Use this with care, as the a long buffer causes longer join times.

    PhotonTargets has values ending on ViaServer. Usually, when the sending client has to execute an RPC, it does so immediately - without sending the RPC through the server. This, however, affects the order of events, because there is no lag when you call a method locally!

    ViaServer disables the "All" shortcut. This is especially interesting when RPCs should be done in order: RPCs sent through the server are executed in the same order by all receiving clients. It is the order of arrival on the server.

    Example: In a racing game you could send the RPC "finished" as AllViaServer. The first "finished" RPC call will tell you who won. The following "finished" calls will tell you who's on the ranks.
  • Hi @redskry, hi @Andrebirnfeld,

    having an action that is 'performed' by two (or more) players at the same time, is always a problem, unless you have server-side logic dealing with that kind of scenario. Using the *ViaServer option seems to be a good idea to check and test if things are working. When the client receives the first RPC, he can set a check value which describes what happened, for example 'There is already a client in sight'. If the client receives the second RPC immediately afterwards, he can check the previous condition first, to see if he has to do something.

    Glad to see you are trying to help each other, please let me know if you have further questions.
  • Thanks for your help !
    I find somethings but my english is not very good so i'm not sur of this explaination

    :Targets, Buffering and Order

    You can define which clients execute an RPC. To do that, use the values of PhotonTargets. Most commonly, you want All clients to call the RPC. Sometimes only Others.

    PhotonTargets has some values ending on Buffered. The server will remember those RPCs and when a new player joins, it gets the RPC, even though it happened earlier. Use this with care, as the a long buffer causes longer join times.

    PhotonTargets has values ending on ViaServer. Usually, when the sending client has to execute an RPC, it does so immediately - without sending the RPC through the server. This, however, affects the order of events, because there is no lag when you call a method locally!

    ViaServer disables the "All" shortcut. This is especially interesting when RPCs should be done in order: RPCs sent through the server are executed in the same order by all receiving clients. It is the order of arrival on the server.

    Example: In a racing game you could send the RPC "finished" as AllViaServer. The first "finished" RPC call will tell you who won. The following "finished" calls will tell you who's on the ranks.
  • I'll test that in the Week and I come back if I find a other way maybe more efficient!
    Thanks for your help ! Have a good day !

    And if someone have a other idea about this case , I'm here