Tutorial or Docs for Unity + Photon

I notice that Photon has extensive documentation for its Visual Studio support, but what about documentation for Photon + Unity?


  • what kind of documentation are you talking about :)

    I ask cause there are 2 kinds of documentation:

    1. Photon server side - they are not in context of VS but just the server side. That they happen to be VS focused has to do with the fact that you can't build it from anything else ;) These documentations are inside the photon install folder and subfolders.

    2. The photon client SDKs for various platforms - these contain documentation for their respective platforms within their install locations
  • We're still working on the Photon Unity Networking package(s). As we currently "just" cover the features of Unity's built-in solution, we hope that extra documentation is not yet the most important area to work on.
    We've got 3 demos in the asset store and the pdf in the download. If you get stuck, please search the forum or post questions.
  • Not to plug my own stuff, but you might want to give it a look anyway. I use Unity3d for my client in my videos. Feel free to have a look at http://www.youtube.com/user/cjrgaming It should give you some insight into getting started with Photon + unity3d.
  • I am also looking for Unity Photon documentation.

    I had downloaded the AngryBots demo but the included pdf looks to be a generic doc about the Unity Photon Plugin. The Readme file is a little obsolete for example it states to use a scene called testScene.unity. Obviously you need to add all 4 scenes in your players build settings during publish to get things working. The demo is a little buggy for me. Many times my 2nd player doesn't show up or demonstrate the animations playing correctly. Also sometimes when I fire on one client the other side keeps firing after I stop.

    So I would appreciate any docs to kick me off on the latest photon with Unity. I would like to test my cloud set up on a completely new Unity Project. Even it's just setting up a test room to join with two network cubes on a flat plane. Then add sync animation yada yada. Thanks.

    I just noticed that the Unity Plugin which is a separate download has it's own DemoWorker test scene in it to help with the above. I guess that is what the readme file is referring too in AngryBots. Please let me know when a Doc file is available for AngryBots thanks. I would also like to see any step by step guide for this plugin thanks.
  • We're still catching up with documentation in respect to Photon Unity Networking, so the best way to get into it is by checking the Worker Demo (in Photon Unity Networking in the Asset Store) and the Viking Demo (another download) plus the PDF in the plugin's folder.

    In general, we hope everything works like Unity's built-in documentation, so if you read up on that, you should be able to use PUN as well.
  • Hi Tobias.

    I had looked through the other examples /pdf. I was hoping to find a demo where the player can interact with something. For example I had created a sphere in the Demo Worker. It falls on the plane. I added a photon view and a regular rigid body component to it. I observed the spheres transform and left everything default: Reliable Delta Compressed. I then had the player attempt to push the ball on the plane but it doesn't seem to work out. The ball stands still for the most part. Sometimes it suddenly rolls away.

    So I guess I'd like to see some short best practice examples on making game objects networkable in photon cloud. On the Unity doc side I was looking at this Multiplayer Tutorial. Maybe there could be a photon c# follow up variation on this.
  • you would best hook up the rigidbody or use something like the networked rigidbody for proper interpolation and prediciton
  • We will take a look at the "Networked Rigidbody" soon. It's part of the Unity networking example and we want to make this run on Photon, too.
    I can't say how precise we can make this though. Networked physics objects are a complex topic and like so often, one solution won't fit all cases.

    We will definitely stick to c#, so a follow up in c# is possible.
  • Thanks Tobias!

    I look forward to seeing the doc. Please keep me in the loop.
    Tomo wrote:
    So I guess I'd like to see some short best practice examples on making game objects networkable in photon cloud. On the Unity doc side I was looking at this Multiplayer Tutorial. Maybe there could be a photon c# follow up variation on this.

    Tobias I decided to give this tutorial a go as it has the NetworkRigidbody example. I converted the JavaScripts to C# and then set things up to run in the photon cloud using the Viking Menu. You can shoot another player and reset their position back to the spawn point. I tested on a Android phone.

    I can probably share my changes as is as a new Photon tutorial but the StarTrooper docs do not explain anything about object clean up. So if you look at the MissileLauncher part (page 19) where missile prefab gets Instantiated yada yada there is no follow up PhotonNetwork.Destroy (page 20) in MissileTrajectory so every missile that ever gets fired will be buffered to fire again naturally for new joining players. Given the current tutorial Tobias how would you best advise purging the Missile Prefabs under one view? I tweaked the example to use RigidAlign's photonView.isMine to enable/disable PlayerControls, MissileLauncher, and NetworkRigidbody as these scripts are attached to the SpaceCraft prefab not main camera.
  • Hmm. I didn't work through the tutorial but I see what you're talking about.
    Having the missiles buffered makes sure that players who join the room will see the missiles already flying around. This can be a requirement or not (maybe noone will join later on).

    There must be some piece of code which decides a missile is destroyed (hit or missed but empty). In this piece, call PhotonNetwork.Destroy for the missile. It should get deleted from the buffer as well.

    If it's not in Photon Unity Networking 1.4, then let us know. We fixed PhotonNetwork.Destroy in 1.4 but maybe you found a case where it's not working.
  • Yeah I had thought the same I had tried putting the PhotonNetwork.Destroy(gameObject); inside MissileTrajectory to destroy the missilePrefab it's attached to but Unity complains there is no PhotonView... Hence my question on how to best use Destroy under one view as I think it would get expensive to add a view for every rocket fired. Or whatever you suggest.

    May I suggest adding PhotonNetwork.Destroy(GameObject go, float sec) to the API ?

    I'm using a Coroutine ATM to kill the missile if it flies off screen 5 secs later)

    Even after attaching a PhotonView to missilePrefab I cannot get PhotonNetwork.Destroy to work properly for this example...

    As a workaround I had used a RPC inside PlayerControls:
    if ((Input.GetMouseButtonDown (0))&&(timer>12))
    			Vector3 position = new Vector3(0, -0.1f, 1) * 6.0f;
    			position = transform.TransformPoint(position);			
    			photonView.RPC("FireMissile", PhotonTargets.All, position, transform.rotation);
    			timer = 0;

    And then MissileLauncher does:
    	void FireMissile(Vector3 position, Quaternion rotation) 
    		Instantiate(missile, position, rotation);
    		//Debug.Log("FireMissile " + position.ToString() ); 

    The touch and fire code is moved from MissileLauncher's Update loop to PlayerControls Update block. MissileTrajectory only needs to execute a Regular Destroy to remove the exploded missiles from the game. I'm sure the timing isn't perfect but it's quick and dirty.
  • ^
    I modded the game so that it can be played on the web too.

    Play a live demo of StarTrooper running on the photon cloud here
  • I just followed the link and the page didn't load. Timeout from webserver.
  • I just signed up here to pos me feelings of total lost-ness...

    I have been eager to try Photon for months now but being a Mac Unity user the whole "You have to use VS" thing just made me give Photon the middle finger. So then I noticed "Wo now support OSX" and I am all excited again. I download the OSX SDK and find myself going "Now what?"

    Now I have to decide between letting you host my servers and having no control over what the server version of my game does or I can manage my own server but I have to figure it out for myself how to get started. Fortunately the website says I can be up and running in 5 minute.s Excellent! So I start reading...

    I go to the Unity Demos page and find I must download a demo from Unity that I must merge with this? Huh? I thought I was downloading the merged demo but first I have to download 2 demos and merge them myself? Interesting. So then they say to see more than just myself in the game I need to run another app.. and and I must place source code inside the folder.... What? c++ code inside my Unity project??? So I get a path to where the files are that I must include but that path doesn't exist in my OSX SDK so I read it again and find the files are in the Server SDK so no I have to download another SDK in order to get my first SDK to work...

    So I go to the page for the Server SDK and see I have a choice between windows, windows, windows or windows...


    Is there ANYBODY, anywhere in the world who can just give me a simple step by step guide to how I get the hell started with Photon because this constant jumping back and froth between the docs only to be blindsided and blocked at every turn is really frustrating the living daylights out of me!!!

    I honestly cannot understand why in the world there is such a big fuss over Photon when just getting it installed on my system has been the single most confusing process in my 15 years of being a programmer... Honestly! WTF?! Why is it so hard to just write a simple:
    "This is how you use our product if you are using Unity on a Mac" tutorial or to say "Sorry, our most excellent of products only works on Windows. Fiddle finger to all you Mac people. La la!" ?

    Someone, please... I am begging you... Answer me just these two questions, please:
    1. Can I use Photon with Unity on a Mac as development platform? (None of this cloud nonsense)
    2. If so, how?

  • 1. No.
    2. See 1.

    The server we built runs only on windows machines. That won't change soon, sorry. It's not against other systems, it's just the way we use windows features that we can't simply port.
    The only alternatives are using the cloud (which you don't like) or rent a windows machine and run Photon there.

    Both, the cloud and the "Loadbalancing" setup in the server SDK play nicely with the client called "Photon Unity Networking". This is our re-implementation of Unity's own Networking classes and works very similar. It's actively developed and doesn't require you to merge demos. Download, import into a empty project and register through the popup wizard (also opens through: Main Menu, "Window", "Photon Unity Networking", "Setup"), run the demo with your assigned appID on the cloud (just for testing).

    Visual Studio is not a must either. It's just the one IDE we support. MonoDevelop and others are most likely able to compile the server logic, too, but we can't guarantee for the performance of it's compiled code. Being a developer for such a long time, you realize that compilers have some impact on the produced code.
  • @CryingRaven:
    It looks, like you are mixing up a whole lot of totally different things, here:
    1. Photon is not Unity only. Unity is just one of many client platforms, which is supported by Photon, the one, with the most users, but by far not the only platform. The OSX client SDK is for running the Photon client natively on OSX, for people developing their games in C++ or objC without using Unity3D at all. If you want to use Photon with Unity clients, then download the Unity client SDK, which from its first release always has worked with Unity on OSX (back in the time of it first releases, Unity was not even supporting WIndows at all).
    2. You do not have to run your servers on OS X, to run your clients on OS X. On serverside we currently only support Windows, but you still can run your clients on many other platforms than Windows.
    3. You do not have to download any demo from the Unity demos page to get the server working. Just download the server-sdk, unzip it and, start the PhotonControl.exe on a Windows computer and install and run instance 1 from the menu. There you go.
    4. There are demos included in any client SDK, including the the Unity one, which run out of the box. For Unity we additionally have integrated Photon in some of the popular demos, which are available from the unity guys. This is an additional service to show you, how you would typically integrate Photon into a more complex project than the simple demos from our client SDKs. As these demos are pretty huge in download size in comparison to our clients SDKs, we do not want to force people to download them every time, when they want to update their clients to a new version, so these are separate and optional downloads.
    5. C++ code inside your Unity project? No, definitely not, we do not tell you to do this anywhere and there definitely is no need to do this for using Photon.
    6. How have you got the idea of searching in our native os x SDK for a path to a folder which you want to mix inside a Unity demo? They have nothing to do with each other at all.

    So, yes, you can use Photon with Unity on Mac as development platform for the client side: Just download the Unity client SDK - thats all what you need therefor.
    No, you can't run the Photon server on a Mac: You will either have to let your client use the Photon cloud or to run your server on a windows machine.