Regarding playing with friends

Options
zohaibjaved
edited September 2014 in Photon Unity Networking (PUN)
Hi,

I want to add an option play with friends using GameCenter and Facebook. What is the best way using photon unity networking ?


My requirements are
Add player as a friend via GameCenter and Facebook
Player can accept add invites.
Should see players online
Should know the connected server.


Can photon unity provide these functionality?

Comments

  • Tobias
    Options
    You can use "Custom Authentication" to make sure your users login with the community accounts you want to support.
    This is described here: http://doc.exitgames.com/en/pun/current ... entication

    You get a userID from those services and with that userID. FB and GC have friends lists. If your Photon client is on the Master Server, it can use FindFriends() and see who's online, etc.
    This is working only for friends connected to the same region and it does not work in a room.

    Invites can best be sent with Photon Chat or some external service. Basically you only need to send a made-up unique room-name to the other player and wait until he/she joins.

    Is your game Turnbased or Realtime?
  • zohaibjaved
    Options
    Thank you for the reply. It is a realtime multiplayer game.
  • Hi,

    I have successfully integrated play with friends into my game using photon chat unity SDK. I am having two issues :

    1. Game connects to photon server at the start of the game.Sometimes when internet connection is slow, then game freezes when PhotonNetwork.ConnectToBestCloudServer is called. It happens randomly so it is very difficult to reproduce.

    2. One user creates the room and invites 2 or more people using photon chat. When 2 people try to join the same room at the same time. Out of 2 out of 10 times, one of them fails to join the room. Retrying 2 to 3 times allows players to join the room.
  • Tobias
    Options
    1: When things freeze, please try to get the log from the player and let us know which versions you use and which platform you're on. Unless we have some chance to reproduce, it's going to be difficult to fix.
    Also: I released new PUN and Unity SDK versions. It makes sense to update both (no matter if PUN Free or Plus).
    See: http://forum.unity3d.com/threads/photon ... st-1778859

    2: You could use JoinOrCreateRoom. This variant doesn't mind who creates or joins the game and is much easier to use for invites.
    I hope that helps.
  • Thanks for the reply.

    1. I am currently using PUN version 1.24. Going to update it soon.

    2. I cannot user JoinOrCreateRoom In my current implementation. Host when created room successfully then he invites other players to the game. It happened when

    - Player A created the room and invited player B and player C.
    - Player B accepts invite and joined the room.
    - When player B was joining, player C also accepts the invite.
    - Player C failed to join the room was called with the info in the screenshot (https://www.dropbox.com/s/1ujkhw6p90yib ... M.png?dl=0)
    - After retrying 3 to 4 times. Player C also joins the game.
  • Tobias
    Options
    You are sure that MaxPlayers is > 2, I guess?
    If so, I would have to take a look myself.
  • Tobias
    Options
    I can't reproduce the issue. I used Photon Chat and sent invites to 3 others. All use JoinOrCreate and all get into the room just fine.
    Some things to keep in mind: Any player must configure the RoomOptions with max players. Only the one who actually creates the room will set it on the server but that's OK. They should all set the same value.

    Which region are you using?
    In best case, update to PUN 1.28. It has several fixes and should be nicer in general.
  • Sorry for the late reply. I created a test as well and it worked fine there. Then I searched through the code and found that JoinRoom function is called twice :S . I changed it and it is now working perfectly fine. Sorry for taking your time and thanks for the support :)
  • Nouman
    Options
    I want to add multiplayer where the player can challenge random people and compete for more coins. and they will be able to compete with other people and the player will have at least 1,000 coins and then they can compete. If they lose, they lose the 1,000 coins and if they win they win the opponents 1,000 coins, and i will add consequences if the player decides to quit the game while playing. If they close out the game while playing, they automatically lose the 1,000 coins and it rewards the other player

    Can I do this with Photon pun2 ??
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Nouman,

    Thank you for choosing Photon!

    Can I do this with Photon pun2 ??
    Yes it's possible.