Frequently Asked Questions
Which Photon product is the right one for me?
This is a difficult question to answer as it depends on the game you are making and the specifics of your project.
However we can recommend the following:
- Watch this talk by our CTO and founder Chris Wegmann at Unite Europe 2017
- Read the comparison page: "PUN vs. Bolt"
- Read the comparison page: "Photon Cloud or Photon Server?"
Feel free to reach out to us if you still have questions.
What is the difference between Photon Realtime and PUN?
Photon Realtime wraps up all generic features needed for the load balancing of Photon. It is a product as much as a defined workflow to use Name Server, Master Server and Game Servers. Photon Realtime (a.k.a. LoadBalancing) is the basis for many games using Photon.
While Photon Realtime is independent from Unity, PUN adds many comfortable features for Unity and makes Realtime (the lower level) even easier to use.
Both products share the same backend, same server applications, same low-level stuff, same core concepts.
At first PUN was meant to be a better UNet (old Unity Networking): preserve a similar API with a more solid backend and rich features.
Then it slowly diverged and became the number 1 solution for multiplayer on Unity.
While we do have a Photon Realtime Unity SDK, PUN has more high level out-of-the-box features like:
- Magic Unity callbacks
- Extra Unity components that serialize and sync. networked objects for you: most important one PhotonView
- PunRPC
- Offline mode
- ...
Read more here.
However, while PUN supports webhooks and persisting room states, it is still not 100% able to restitute networked objects' state in the scene(s) when loading a saved game.
Read more here.
What is the difference between LoadBalancing API and Photon Realtime?
LoadBalancing API and Photon Realtime can be two different names for the same thing.
The LoadBalancing API or the LoadBalancing Client API is the programming interface available in the client SDKs we provide for the Photon Realtime product.
Photon Cloud
Is Photon Cloud down?
You can check Photon Cloud status here.
What is the default Photon region?
Clients should be able to connect to Photon Cloud as long as at least one region is available.
So to guarantee this, a default value is configured or is used when the developer does not explicitly set one or choose "Best Region" option.
The default value could vary by client SDK.
In native SDKs, it is the value at index 0 of the region list returned by server in OpGetRegions
.
On Unity and DotNet SDKs, the default region should be "EU".
Is it possible to disable some regions?
Yes.
It works in the other way around by defining a list of allowed regions.
Read more about the "Dashboard Regions Filtering".
Photon Bolt
What is the Strict Comparison?
Strict comparison does (a.x != b.x) || (a.y != b.y) || (a.z != b.z)
instead of using the built in a != b
comparison for vectors which does an approximate. It is useful if you have very small changes that you need replicated.
Is there a way to make a redistributable Bolt Server build?
Yes, Bolt support the creation of headless servers, so you will be able to run it on any computer you want.
If you are using Bolt Free, that uses Photon Cloud, this will just publish a room so other players can join, if you are using Bolt Pro, you can still run it locally or on any cloud service, just need a way to transmit to other players on which IP to connect to.
We also have a simple Headless server sample available here.
Do I need to lag compensate projectiles like rockets?
For weapons that fire projectiles, lag compensation is more problematic.
For instance, if the projectile lives autonomously on the server, then what time space should the projectile live in?
Does every other player need to be "moved backward" every time the projectile is ready to be simulated and moved by the server?
If so, how far backward in time should the other players be moved? These are interesting questions to consider.
In Half-Life, we avoided them; we simply don't lag compensate projectile objects (that's not to say that we don't predict the sound of you firing the projectile on the client, just that the actual projectile is not lag compensated in any way).
More info here
How to clear all Bolt Assets on a project?
All Bolt assets are serialized into the project.json
file, so to clear out:
- Close Unity;
- Delete the
<Project Folder>/Assets/Photon/PhotonBolt/project.json
file; - Open Unity;
- Compile Bolt,
Bolt/Compile Assembly
menu;
What is the recommended configuration for using Bolt Free for headless servers on EC2?
Snippets
Here is a list of small pieces of code that can help you to develop your game.
How to Teleport?
By default, Bolt will automatically interpolate/extrapolate an entity when the distance it moves is less than the Teleport Threshold
specified in the entity.
Anything over this it forces a teleport which skips smoothing, and this happens automatically.
You can force a teleport with Bolt.IState.SetTeleport(NetworkTransform transform)
which essentially queues up a request for the next position update sent to the client to force a teleport regardless of settings (for one send tick - the flag gets set back to false after it is sent).
C#
void Teleport(Vector3 newPosition)
{
state.SetTeleport(state.transform);
player.transform.position = newPosition
}
How do you know if there are no sessions when searching if SessionListUpdated does not get called in that case?
For example, before 1.2.9, if you’ve set the room list update to 5 seconds, you would need to wait for 5 seconds to receive the callback.
Then you will know that there are no sessions available.
Now, starting on Photon Bolt 1.2.9, you can just start a coroutine process when you’ve connected to wait the same 5 seconds.
We've included an example implementation on the basic menu script that comes with the Getting Started
sample.
Here is a the main parts:
C#
public class Menu : Bolt.GlobalEventListener
{
private Coroutine _timerRoutine;
// ...
public override void BoltStartDone()
{
// ...
if (BoltNetwork.IsClient)
{
// This will start a server after 10secs of wait if no server was found
_timerRoutine = StartCoroutine(ShutdownAndStartServer());
}
}
public override void BoltShutdownBegin(AddCallback registerDoneCallback)
{
registerDoneCallback(() =>
{
BoltLauncher.StartServer();
});
}
public override void SessionListUpdated(Map<Guid, UdpSession> sessionList)
{
// Stop background routine if a server was found
if (_timerRoutine != null)
{
StopCoroutine(_timerRoutine);
_timerRoutine = null;
}
}
}
How to set a specific port when starting a Game Server?
When running a Photon Bolt instance as a Game Server, you are able to configure which IP/port the peer will try to bind.
This is useful if you are hosting your game on Cloud Service, for example, and have a limited range of ports to use.
By default, Bolt will let the Operating System elect a port to bound the internal socket, but this can be overwritten by calling the right overload of BoltLauncher.StartServer
, as shown below:
C#
public static class BoltLauncher
{
// ...
public static void StartServer(int port = -1);
public static void StartServer(UdpEndPoint endpoint, string scene = null);
public static void StartServer(UdpEndPoint endpoint, BoltConfig config, string scene = null);
// ...
}
So, you could start your server this way:
C#
void StartBoltServer()
{
// Custom Port number
BoltLauncher.StartServer(<custom port>);
// OR
// Custom IP and Port number
BoltLauncher.StartServer(new UdpEndPoint(UdpIPv4Address.Parse("<custom IP>"), <custom port>))
}
How to change the Bolt Default Configuration using Code?
If you want to customize the bolt configuration through code before starting your server or client, you can do so by calling BoltRuntimeSettings.GetConfigCopy
, modifying the returned object and then passing it as the last argument to StartClient or StartServer.
You have access to more settings that are not exposed in the Bolt Settings window through code.
C#
BoltConfig config = BoltRuntimeSettings.instance.GetConfigCopy();
// change any settings you want on the config object here,
// be aware that bolt will not verify/limit any settings when you do
// it directly in code, so you can break things completely by supplying
// incorrect/invalid config values.
BoltLauncher.StartServer(new UdpEndPoint(UdpIPv4Address.Any, 27000), config);
How to detect an Internet Connection Lost in Bolt?
By default, when you lost the connection with the internet, Bolt will detect the lack of connection with the Photon Cloud service and with the remote server or clients. In all the cases, the local instance will be shutdown after the timeout occurs, this mainly depends on the side of the connection (server or client) and the connection type.
At shutdown, you will receive the following callback on any Bolt.GlobalEventListener
currently running on the scene:
C#
public override void BoltShutdownBegin(AddCallback registerDoneCallback, UdpConnectionDisconnectReason disconnectReason)
{
registerDoneCallback(() =>
{
// Will show disconnect reason.
Debug.LogFormat("Shutdown Done with Reason: {0}", disconnectReason);
// Show the current connectivity of the peer
ConnectivityCheck();
// Lods the Scene at index 0
SceneManager.LoadScene(0);
});
}
void ConnectivityCheck()
{
if (Application.internetReachability == NetworkReachability.NotReachable)
{
Debug.Log("NotReachable");
}
else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
{
Debug.Log("ReachableViaCarrierDataNetwork");
}
else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
{
Debug.Log("ReachableViaLocalAreaNetwork");
}
}
To check if you have disconnected by the lack of Internet Connection, take a look at the Application.internetReachability
property available through the Unity API.
Billing
Do you have special offers for students, hobbyists or indies?
All our products have a free tier and a one-off entry-plan.
We also usually take part in Unity's asset store sales and occasionally give vouchers to lucky ones.
Can I combine more than one 100 CCU plan for a single Photon application?
No.
The 100 CCU plans are not stackable and can be applied only once per AppId.
If you purchase multiple PUN+ asset seats then you must redeem each 100 free CCU for a separate AppId.
If you need more CCU for a single app, the next higher plan is the 500 CCU one.
If you subscribe to a monthly or yearly plan, then you will still keep the 100 CCUs for 12 months on top of / in addition to the CCU from your monthly/yearly plan.