Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: escpodgames on August 01, 2013, 12:06:49 AM

Title: Photon - Play with friends[SOLVED]
Post by: escpodgames on August 01, 2013, 12:06:49 AM
Hi,

I have been thinking about this for a while now and figured Id put it out there to see if there are any other/different ideas out there.

Basically my current game needs to be able to create a room (yes I'm using Photon) and only friends can join and or see. What is a friend?! Options are Facebook friends (best option) GameCenter friends (second best option)

The photon side of things would be rather easish?! Create a room that has a unique name to the Master, this could be the users facebook http as an example (just encase there are more than one John Smith playing my game at the same time) From there each user would check the list of rooms with the list of their facebook friends http address (is that very practice?) provided I haven't found a means to get facebook friends info yet. Gamecenter is the back up plan.

Just thought id see if anyone else has tackled this issue/problem.

Cheers
Andrew
Title: Re: Photon - Play with friends
Post by: jeanfabre on August 02, 2013, 10:59:07 AM
Hi,

 basically, dealing with this is something separate from Photon in terms of logic. It's up to you to deal with who  can view/access/join rooms.

you have two ways to go about room listing:
-- you can make room invisible, and you have your own server logic ( php/mysql or else) to maintain accessible rooms based on friends listing, and your game simply get that list
-- rooms are visible to all, but your interface simply filter them, this is the same principle as what you would implement on your own server side

as for friend listing, yes, you can use facebook  and graph queries. If you use your own system, you will need a lot of work to get to a point where you have your member management with all the tools to deal withs friends ( inviting, accepting, black listing, etc etc etc), so if you use a social system ready made, I strongly advice to do so, if you never tackled such system before.

bye,

 Jean
Title: Re: Photon - Play with friends
Post by: escpodgames on August 02, 2013, 06:57:21 PM
Hi,

Thanks for your input Jean :D Personally, anything server related scares the bajesus out of me just because I've never had to deal with anything overly complex .... I'm using Playmaker after all :P

I think the best bet is to filter the rooms via the interface, as you said. I've already designed the Ui and how it will/could work its just a matter of how to filter the users.

Facebook graph queries is where I'm headed, I've taken a look at a bunch of other networked room based game (Poker is a good example) where they allow other people to be added to your friends etc but I don't think that is needed for my game. I just need a way to find your friends and play with them otherwise you can play with random people.

P.S. Thank you so much for your Photon tutorial (and/or Alex) was rather easy to setup and everything seems to be working .... just need the friends aspect. Back to writing Facebook actions for me :D
Title: Re: Photon - Play with friends [SOLVED]
Post by: jeanfabre on August 07, 2013, 05:07:16 AM
Hi,

as I looked closer, Photon HAS a friend list system. So I'll be working on this to provide access to this built in friend system. It will not be in the very next release, but likely in the following one.

bye,

 Jean
Title: Re: Photon - Play with friends [SOLVED]
Post by: escpodgames on August 07, 2013, 06:37:18 AM
Sweet, I might have to rethink the way I do "playing with friends" then as I'm planning to submit my game around 13 weeks from now ... unfortunately this aspect is pivotal to its potential success :(

Might be able to create a room per player with their Facebook ID being the room name, then use that somehow to get a sudo 'play with friends' system.
Title: Re: Photon - Play with friends
Post by: escpodgames on August 07, 2013, 06:44:45 AM
I guess there in no way to search the room titles so that idea is out.

Does GUILayout ToolBar With Players give us access to all the player names? :D
Title: Re: Photon - Play with friends
Post by: escpodgames on August 07, 2013, 07:51:14 AM
"There is a new operation opFindFriends(). You pass an array with the names of the players that you want to look up. The client then asks the master server (the operation will fail, when you are in a game room, which implies being on a game server), if there are any players with these player names online and in which rooms they are, if in any.
You would just pass your list of players into this operation, but handling who is on this list and who is not, is up to you. Functionality therefor is not provided"

Sounds like exactly what I need, Via Facebook I the friends names, opFindFriends looks them up and gives back which players are online and in what room!
Title: Re: Photon - Play with friends
Post by: jeanfabre on August 07, 2013, 08:36:10 AM
Hi,

 where did you get this?

bye,

 Jean
Title: Re: Photon - Play with friends
Post by: escpodgames on August 07, 2013, 07:38:23 PM
http://forum.exitgames.com/viewtopic.php?f=8&t=2864

"Photon is only able to find players by name. It does not provide the actual social component (adding friends, etc). This is up to you or a middleware of your choice.
We decided against designing and implementing another friend listing in Photon when most game-developers already have a favorite social API."

If its not much extra work, would this be possible for the next update as I'm building the 'social component' actions atm it would be a very powerful addition combine with Array maker.
Title: Re: Photon - Play with friends
Post by: jeanfabre on August 08, 2013, 03:19:17 AM
Hi,

 Yes, this is planned. I'll need to make sure it works and all, so I am not sure it will go for the very next release, but definitly the next big thing for me to work on for Photon.

bye,

 Jean
Title: Re: Photon - Play with friends
Post by: MABManZ on May 16, 2016, 03:50:09 AM
Hi Jean!

Was this ever further developed?
Title: Re: Photon - Play with friends
Post by: jeanfabre on May 20, 2016, 02:13:38 AM
Hi,

 not really, The problem being that scripting is unavoidable in the case of friends because they need to be pulled from various systems and servers that you'll need to hook up with and provide server side scripts to get the list of friends from the social systems you'll be using and giving access to from within your games.

 So that's tricky indeed... What kind of back end you are thinking of using to manage users and friends list?


Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: MABManZ on May 20, 2016, 04:45:18 AM
I'm using Steamworks SDK, unfortunately my coding/scripting is weak, so I can't figure out how to use the Steam Overlay for invites, as this would be more intuitive to users.

However, using the Steamworks.NET Playmaker actions I can already populate a friends list using their Steam ID and assigning it as their Photon ID.

All I really need is an action to populate an array using the information from the OpFindFriends() function (https://doc-api.photonengine.com/en/dotnet/current/class_exit_games_1_1_client_1_1_photon_1_1_load_balancing_1_1_load_balancing_client.html#a797304e9d94079efad420f4e6f62ce5f) for Photon. Using this, users can at least get the room name of a friend's room and join manually.
Title: Re: Photon - Play with friends
Post by: escpodgames on May 20, 2016, 04:51:24 AM
I'm in the same boat, getting friends is not the issues it's finding them in rooms.
Title: Re: Photon - Play with friends
Post by: jeanfabre on May 20, 2016, 08:00:47 AM
Hi,

 ok, good, let me work on this then. Thanks for the clear explanations of what you need, it always help :)

Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: MABManZ on June 08, 2016, 11:00:07 AM
Hi Jean,

Any progress on this? Sorry to bug you, I could use this soon or I'll have to get started on a workaround (manually entering a room name)
Title: Re: Photon - Play with friends
Post by: jeanfabre on June 10, 2016, 03:28:54 AM
Hi,

 I'll likely get on it soon, but havent' started sorry... But thanks for the bump it helps!

Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: jeanfabre on June 22, 2016, 09:57:32 AM
Hi,

 Ok, support for FriendList is now available ( get the latest on Ecosystem or wiki if ecosystem is capricious).

use PhotonNetworkFindFriends to make the request ( ONLY WORKS IN LOBBY)

 you'll have a new "PHOTON / FRIEND LIST UPDATED" which is only when you receive this that you should query it using

PhotonNetworkGetFriendsOnlineStatus
PhotonNetworkGetFriendsinRoomStatus
PhotonNetworkGetFriendsRoomStatus

 It's now mandatory to have PlayMaker 1.8, because I started using FsmArray with friendList.

Let me know how it goes.

 Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: MABManZ on June 22, 2016, 09:26:59 PM
Awesome!

Thanks Jean, I will implement these this week and let you know if I hit any issues.
Title: Re: Photon - Play with friends
Post by: ermak on June 23, 2016, 07:20:46 AM
This is great! New "Friends" actions.
I'll be happy for any simple demo of this feature too (unity package or video).

By the way... any chance in the future for "Photon change owner" action?
https://doc.photonengine.com/en/pun/current/tutorials/ownership-transfer
Title: Re: Photon - Play with friends
Post by: jeanfabre on June 23, 2016, 09:11:49 AM
Hi,

 It's tricky to do a demo, because you need to come up with a social system to have a friend list being created. Else it means that for testing, you'll have to instantiate several instance of the demo, name each player of them instance properly, and then test on the Unity editor... this is I feel too much for a demo...

basically, you name each your player with a unique name, which is usually a facebook id or some social id.

then, your social network gives you  the list of your friends id, you store them id in an FsmArray, and you feed that inside the FindFriend Action, and you wait for "PHOTON / FRIEND LIST UPDATED", which then allows you to use all the get Friendxxx actions for who's online, what room they are in, etc etc.

 So that in itself is really simple.

I'll work on the change owner action yes. Should have that by tomorrow.

Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: escpodgames on June 23, 2016, 05:30:08 PM
FindFriend Action!!!
OMG I can't wait! Thanks a TON Jean!
Title: Re: Photon - Play with friends
Post by: MABManZ on June 25, 2016, 04:38:14 AM
Hi Jean,

The "PHOTON / FRIEND LIST UPDATED" event never seems to trigger after using the Find Friends action, and the other actions are unable to receive friend status information.

Also, "PHOTON / FRIEND LIST UPDATED" does not appear to have an existing global event, such as the older Photon events. Am I missing something? The "failure event" does not happen after calling the find friend action, so I assume it is using the action successfully.
Title: Re: Photon - Play with friends
Post by: jeanfabre on June 27, 2016, 08:17:47 AM
Hi,

 My test works fine.

 Get the PlayMaker worker demo, and play it, when in the lobby, locate the "menu" GameObject, and the fsm "Friends Test", trigger "FIND FRIENDS" from the PlayMaker inspector.

 You should then be receiving "PHOTON / FRIEND LIST UPDATED"

 Let me know how it goes. Remember, it only works if you are in the lobby.

Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: MABManZ on June 29, 2016, 04:31:33 PM
OK, I got the  "PHOTON / FRIEND LIST UPDATED" to work, but only ONCE.

It appears that using the Find Friends action causes a Photon disconnect immediately afterwards.

The connection state is returning as "not connected", and if I use another connect action, it will work again ONCE, and disconnect again.

edit: For now at least I can force a refresh of the list by constantly reconnecting
Title: Re: Photon - Play with friends
Post by: jeanfabre on June 30, 2016, 07:29:17 AM
Hi,

 ok. very odd... I am witnessing any disconnection after I request and receive "PHOTON / FRIEND LIST UPDATED".

 Are you using the demo worker or your own scene and logic?

You only get friend list update when you request it first of all. You won't get an automatic callback when a friend connects you have to query it. do that every minute maybe.

Bye,

 Jean
Title: Re: Photon - Play with friends
Post by: MABManZ on July 03, 2016, 03:51:41 AM
I am using my own logic to populate the friends list array, but followed very closely with the example. I've got everything working correctly now!

Things to watch out for:

- The process can hang or disconnect if you attempt to use Find Friends on an array with null values in it
- Resizing your array to the size of the friends list will avoid this issue


Thanks for the help Jean!
Title: Re: Photon - Play with friends
Post by: jeanfabre on July 04, 2016, 09:16:59 AM
Hi,

 uhm, interesting comment on null friends references. It of course doesn't make sense to feed an array with null value in this case, so let's keep it as is ok? or do you think I should implement a clean up or event being fired if friend list contains null values?

 Bye,

 Jean
Title: Re: Photon - Play with friends[SOLVED]
Post by: MABManZ on July 04, 2016, 01:30:01 PM
For users who may not understand a lot of coding (like me) it may be helpful, it took me several hours to figure out why this was happening so it may help save them some time!

But also it was a good lesson for me with working with arrays :)
Title: Re: Photon - Play with friends
Post by: Sid on August 15, 2016, 04:48:33 PM
I'll work on the change owner action yes. Should have that by tomorrow.

Hey, @jeanfabre.  Any luck on getting the Photon Takeover action (this.photonView.RequestOwnership()) going? 

We could really use it, as we transition to scene objects.

Thanks so much!
Title: Re: Photon - Play with friends[SOLVED]
Post by: jeanfabre on August 17, 2016, 06:55:11 AM
Hi,

 It's done already :) waiting for the next iteration of Photon to ship it, which will happen this week.

 Bye,

 Jean
Title: Re: Photon - Play with friends[SOLVED]
Post by: Sid on August 17, 2016, 09:30:25 AM
Awesome! 

I managed to use code from Get Photon View ID and add that line to it, and it seems to work if anyone needs a simple version in the meantime.

Thanks, Jean!  You and the crew make games happen.

EDIT: Removed failed attempt at Photon script.

Title: Re: Photon - Play with friends[SOLVED]
Post by: jeanfabre on August 17, 2016, 09:53:01 AM
Hi,

 Carefull, you need to also spread this across the network, that's not enough to request, you need to apply this back on all instances using TransferOwnership()

Check out the PhotonViewRequestOwnerShip (https://github.com/jeanfabre/PlayMaker--ExitGames--PhotonUnityNetworking_U4.3.4-Library-/blob/master/Actions/PhotonViewRequestOwnerShip.cs) and PlayMakerPhotonProxy (https://github.com/jeanfabre/PlayMaker--ExitGames--PhotonUnityNetworking_U4.3.4-Library-/blob/master/Scripts/PlayMakerPhotonProxy.cs) method OnOwnershipRequest()

Bye,

 Jean

Title: Re: Photon - Play with friends[SOLVED]
Post by: Sid on August 17, 2016, 03:17:42 PM
Thanks again, Jean.

I humbly redact my submission.
Title: Re: Photon - Play with friends[SOLVED]
Post by: jeanfabre on August 18, 2016, 05:28:43 AM
Hi,

 Actually, your action was right, you just needed the extra script ( in photon proxy) to listen to transfer changes.

 I am working on a demo so that you can testify ownership changes, this will be easier to understand how everything works.

 Bye,

 Jean
Title: Re: Photon - Play with friends[SOLVED]
Post by: Sid on August 18, 2016, 12:00:44 PM
Very much looking forward to the demo.

With our scripts updated to the two you posted, whenever a client enters a room it does not recognize the owner of the Photon View.  It just sees them all as Scene objects, regardless of them being taken over previously.

Are we missing some step?

Thanks, man!
Title: Re: Photon - Play with friends[SOLVED]
Post by: jeanfabre on September 12, 2016, 07:51:20 AM
Hi,

 FindFriends is now available. Get the latest on the Ecosystem.

 Let me know how it goes and if you have more questions :)

 Bye,

 Jean
Title: Re: Photon - Play with friends[SOLVED]
Post by: ermak on September 12, 2016, 10:48:39 AM
Thanks for this!
I am happy to see you updating wiki page too. Because you know, sometimes ecosystem not working.

Oh.. yeees "RequestOwnerShip" :)
Title: Re: Photon - Play with friends[SOLVED]
Post by: jeanfabre on September 13, 2016, 02:04:14 AM
Hi,

 when ecosystem is not working, everything is available either on github or on snipt:

https://github.com/jeanfabre?tab=repositories

https://snipt.net/search/?q=playmaker

Bye,

 Jean