13. Making the multiplayer part 2. Oculus friend invites

Hello, it’s me again, you friendly neighborhood spiderman/programmer Jammu. Today we will continue our technical saga with the friend invite system. I will be using Unity 2019.4 LTS, Oculus 23.1 and PUN 2.22

 

Oculus’s side of the friend inviting was interesting to say the least. Oculus lacks any proper examples on how to do pretty much anything and they don’t tell you a thing about the steps a developer has to do to achieve anything. It doesn’t help the situation that nothing on their SDK is commented and all documentation I could find was deprecated, nice. 

 

Firstly to kick things off I was stuck on getting the Oculus entitlement check to give me any feedback on Unity editor, it wouldn’t pass or fail. Just nothing. Of course the most logical thing was the solution (notice sarcasm). I needed to make a template build of the project, upload it to the Oculus dashboard on the Rift version of the game, install the game on my machine from Oculus app and allow untrusted sources. Only cost me a day, couple of energy drinks and a headache to fix this stupid problem. It would have been so much easier if any of this was mentioned somewhere.

 

If you are starting to make any multiplayer functionality, make sure to pass the “Data use checkup” on the Oculus dashboard before you even try to get any data from their backend. 

 

Now that the Oculus user has the entitlement and we have access to the users data, it’s pretty simple to go forward, Get the users data from Users.GetLoggedInUser().OnComplete() callback and get user’s friends that are inevitable by calling Rooms.GetInvitableUsers2().OnComplete() callback. Next we make an Oculus room (not to be confused with PUN rooms) by calling Matchmaking.CreateRoom2() callback, don’t forget to also set up the “pool” of this function on the Oculus dashboard. At this stage, we don’t yet worry about cross platform stuff, that will be in part 3.

 

Friend’s getted from GetInvitableUsers2() callback

Next up is the invitation system. In Oculus, you need to utilize aforementioned Rooms.GetInvitableUsers2() callback to get a user’s invite token to ask them to join the room with you. I decided to get this invite token when the host asks a friend to join their game. Then we can simply call Rooms.InviteUser(roomIDOculus, inviteToken) to ask them to join our room. Friend then gets this invitation on the Rooms.SetRoomInviteReceivedNotificationCallback() callback, so we can display the ingame panel that the user has been invited to a room. Next we can do the same thing as on the Steam, and use the roomIDOculus as a room code to use with Photon.

 

So we are just using the Oculus room as a transport layer to send our rooms data so we can use it to create a Photon room. We still handle all the connecting, kicking etc. on the PUN side, so we can repurpose the code better.

 

In the next post we will be taking a deep dive to the cross platform side.

 

Jammu

Random development quote: “Tää koko koodipohja on 500 riviä puhdasta paskaa ja spagettia”

 

Join Cave Digger Discord!

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

MeKiwi Oy

Njetwork Inn
Isokatu 56
90100 OULU

VRkiwi is a trademark owned by MeKiwi Oy

MeKiwi Oy

Njetwork Inn
Isokatu 56
90100 OULU

VRkiwi is a trademark owned by MeKiwi Oy