Git Product home page Git Product logo

photonvr's Introduction

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:

photonvr's People

Contributors

fchb1239 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.