Frequently Asked Questions

Here is a compendium of our Frequently Asked Questions.

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.

Back To Top

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.

Back To Top

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

Back To Top

How To Clear All Bolt Assets On A Project?

All Bolt assets are serialized into the project.json file, so to clear out:

  1. Close Unity;
  2. Delete the <Project Folder>/Assets/Photon/PhotonBolt/project.json file;
  3. Open Unity;
  4. Compile Bolt, Bolt/Compile Assembly menu;

Back To Top

What Is The Recommended Configuration For Using Bolt Free For Headless Servers On EC2?

>Firewall Configuration
Firewall Configuration.

Back To Top

Snippets

Here is a list of small pieces of code that can help you to develop your game.

Back To Top

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).

void Teleport(Vector3 newPosition)
{
    state.SetTeleport(state.transform);
    player.transform.position = newPosition
}

Back To Top

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:

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;
        }
    }
}

Back To Top

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:

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:

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>))
}

To Document Top