Skip to content

fchb1239/PhotonVR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Unity Package containing all the necessary components to do VR networking with Photon

Download Discord

Documentation

By default everything is set up for a super simple system, obviously you can code some stuff yourself to make everything work for your application.

You need to have PUN 2 and Photon Voice 2 in your project before importing this You also need TextMeshPro - that's built into unity, you just gotta go into the Player prefab and press Import TMP Essentials.

Start off by going in Resources/PhotonVR/Prefabs and dragging everything in there into the scene.

Then, put your Photon AppId into AppId and Photon Voice AppId into VoiceAppId, then put in a region - the default is "eu". Click here to see a list of regions

Then drag in your controllers and headset into Head, Left Hand and Right Hand - set the colour to the default colour.

Set Default Queue to the queue you want to automatically load into when the game starts and set the Default Room Limit to the maximum amount of players you want in a default room.

Connect On Awake makes it so when the game loads you instantly try to connect, Join Room On Connect makes it so it instantly joins the Default Queue with the Default Room Limit when you connect to the server.

Including Photon.VR

using Photon.VR;

Connecting to the servers

PhotonVRManager.Connect();

Switching Photon servers

PhotonVRManager.ChangeServers("AppId", "VoiceAppId");

Connecting to the servers authenticated

// These will not actually work, you need to set this up with PlayFab or something else
string username = "MYID";
string token = "MYTOKEN";
PhotonVRManager.ConnectAuthenticated(username, token);

Switching Photon servers authenticated

// These will not actually work, you need to set this up with PlayFab or something else
string username = "MYID";
string token = "MYTOKEN";
PhotonVRManager.ChangeServersAuthenticated("AppId", "VoiceAppId", username, token);

PlayFab Photon authentication documentation

Joining rooms

// It will only join people on the same queue but the room codes themselves are random
string queue = "Space";
// Optional
int maxPlayers = 8;
PhotonVRManager.JoinRandomRoom(queue, maxPlayers);

Joining private rooms

string roomCode = "1234";
// Optional
int maxPlayers = 8;
PhotonVRManager.JoinPrivateRoom(roomCode, maxPlayers);

Switching scenes

int sceneIndex = 1;
// Optional
int maxPlayers = 8;
PhotonVRManager.SwitchScenes(SceneIndex, maxPlayers);

Setting name

PhotonVRManager.SetUsername("fchb1239");

Setting colour

Color myColour = new Color(0, 0, 1);
PhotonVRManager.SetColour(myColour);

Cosmetics

To put on cosmetics you can use two functions to do the job. You can put on an entire set like so

PhotonVRManager.SetCosmetics(new Dictionary<string, string>
{
    { "Head", "VRTopHat" },
    { "Face", "VRSunglasses" }
    // And so on
});

Or if you want to do one at a time (like if you have a button with a specefic cosmetic) then do like so

PhotonVRManager.SetCosmetic("Head", "VRTopHat");

If you set a cosmetic part to a cosmetic that doesn't exit, it won't equip anything. So if you want to clear the head of cosmetics do like so

PhotonVRManager.SetCosmetic("Head", "");

It's the same story with SetCosmetics.

Every body part on the player has a child named something with "Cosmetics", under those you put the models of the cosmetics you want. You have to rename the object to the ID of the cosmetic, let's say you put on a hat with the ID "VRTopHat" then under the Cosmetics child of the head you put your model and name it "VRTopHat", like this:

About

A Unity Package containing all the necessary components to do VR networking with Photon

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages