Send and recieve only if within a zone.(UNITY)

Options
I'm trying to work on a system which will prevent photonViews from sending information like position and rotation while not being in the same trigger collider.

For example: there are 2 trigger colliders, called: zone1 and zone2.

-player1 has spawned in zone1
-player2 has spawned in zone1
-The players send each other the position and rotation.
-player2 leaves to zone2
-player1 and player2 wont send each other the position and rotation anymore
-player2 has returned to zone1
-player1 and player2 are now sending the position and rotation again.

How do I accomplish such a thing?
How do I prevent players from sending specific information while not being in the same zone at all?
How do I make players send the position and rotation only to other players in the same zone and not in other zones?

**Note: it all happends in the same scene.

Many thanks for anyone who will respond to this issue! :)

Comments

  • Marek
    Marek
    edited March 2014
    Options
    Hi, i think one way would be implement that on the server.
    But maybe it can be done by using OpRaiseEvent where you can specify who will receive your message by Actor ID list.
    However there can be problem that it don't work with automatic photon serialization and you will have to turn off that serialization and handle it yourself by sending all data with OpRaiseEvent (i think serialization raise events anyway) so it should work OK.

    Thats my opinions, wait for photon team maybe they have more straight forward answer :)
  • Tobias
    Options
    Are you using PUN or the "plain" Unity API?
    Photon's Rooms have "Interest Groups", which you can leverage. Clients have to subscribe to those Groups to get events that are sent to those. If you target events to those groups based on location (or triggers), you can limit what each clients gets.

    There are only 255 (one byte as ID), so it's not likely to work for a seamless world, however.
    You should also keep in mind that even reliable events don't arrive at all clients if you use Groups. This might look like they are lost and you might miss updates.
  • benk0913
    Options
    I am using pun, and I am targeting to have one room, in a 2d scene that will contain the entire game, people will just wont load the entire scene but the current place they are in, they could teleport between locations; The thing is that I wish to prevent players in the same room to send each other useless information while not being in the same location..

    I tried to have the stream.sendnext to be the location, if the location is the same as the player it'll send the rest of the send nexts but it didnt work for some reason.. So I try to find an alternative, or a correct way with it.

    Please, if you can, help me out. :)
  • Tobias
    Options
    benk0913: See above. You can use "Groups".
    Each PhotonView has a group field which you can set by code. This defines in which group this view's updates are sent.
    With PhotonNetwork.SetReceivingEnabled you can define which groups this client gets info from. With SetSendingEnabled, you can define if you want to skip sending messages for specific groups (photonViews in send-blocked groups will skip sending their updates to the server).