PUN Classic (v1), PUN 2 and Bolt are in maintenance mode. PUN 2 will support Unity 2019 to 2022, but no new features will be added. Of course all your PUN & Bolt projects will continue to work and run with the known performance in the future. For any upcoming or new projects: please switch to Photon Fusion or Quantum.

1 - Project Setup

<< Tutorial Overview

Starting from this document, we will review all details about the Bolt Advanced Tutorial, how it was build and how you can use this information the create your own game using Photon Bolt. You will learn about:

  • Authoritative movement, shooting and game logic;
  • Replication of animation, transforms and game object state.

Basic Settings And Development Features

After completing the instructions on the Overview document, you can build and run the demo. From now, we will start building your own version of the same game. Before we get started with the tutorial, open up the Bolt Settings window which you can find at Bolt/Settings in the top menu.

bolt settings window
Bolt Settings window.

Most of the settings here we can ignore for now, but look at the bottom Miscellaneous settings and make sure that Toggle Key is set to something easily accessible for you and also that Visible By Default is checked. This tells Bolt to always create an in-game console for you when it starts so that we have an easy way to get information from Bolt.

Create a new folder in the root of your project where you will put the game assets. We will call this folder as Tutorial throughout this tutorial. Create the following folders inside of your new folder.

  • Scripts
  • Scenes

Your folder structure should look like this:

basic folder structure
Basic folder structure.

Inside the Assets/samples/AdvancedTutorial/scenes folder there is a preexisting level that we are going to use, you are free to make your own before we continue. If you chose to use our level, select and duplicate (Edit/Duplicate menu or by pressing the corresponding shortcut) the scene at Assets/samples/AdvancedTutorial/scenes/Level1, this will create a new scene Level2 into the same folder, just move it to your own Tutorial/Scenes folder. Our level looks like this.

game level scene
Game level scene.

If you've duplicated the Level1 scene, you will also need to include a new Layer on your project. Open up the Edit/Project Settings/Tags and Layers settings. Make sure your layer settings match the following ones:

bolt game layers
Bolt game Layers.

We also need a Menu scene so that we have an easy way of starting our game while developing it. Bolt comes with a simple script which helps us to do this. Create a new scene called Menu into your Tutorial/Scenes folder and open it, on the Main Camera game object attach the script found in Assets/sample/BoltInit.cs (you can find the latest version of this scripts on the samples repository), as shown below.

main menu scene
(1) Main Menu scene, (2) Main Camera selected with (3) the `BoltInit.cs` script.

Now that we have the Menu scene and our in-game (Level2) scene, we need to setup these into the Build Settings. Make sure that Menu comes before Level2.

main menu scene
Build Settings with the new *Main Menu* and *Level2* scenes.

While in the Build Settings window, click the Player Settings... button. Under Settings for PC, Mac & Linux Standalone verify that you have the following settings correct.

  1. Default Is Full Screen - DISABLED
  2. Default Screen Width - 640
  3. Default Screen Height - 360
  4. Run In Background - ENABLED
  5. Display Resolution Dialog - DISABLED
recommended player settings
Recommended Player Settings.

You can obviously pick whatever width/height you want, but to run a couple of clients at the same time, 640:360 is a good resolution. Before building a standalone, remember to execute the Bolt Compiler running the menu at Bolt/Compile Assembly. If you build a standalone version of your project and start two copies of it, you will be greeted by the following screen and from there you can run a Server or Client, equal to what you have done on the Overview page. But you will notice that when you enter the game, no player is spawned, this is an expected behavior as we haven't created any script to handle players yet, since we don't have a camera inside our Level2 scene, all we get is the blue background from the previous scene.

standalone build on the main menu
Standalone build on the Main Menu.

Testing Bolt: The Quick Way

Photon Bolt includes a tool to run several instances of the game at the same time, so you can test with a bunch of clients an get a better feel of your game. Of course that you could just run by hand new instances of the standalone binary and connect one by one to a server running on your editor, for instance, but this way is much faster.

In order to use the tool, open up the Bolt/Scenes menu, it will show a window that looks something like this.

bolt scenes debug start
Bolt Scenes Debug Start.

Bolt Scenes window description:

  1. Type of player to run on the Editor (None, Server, Client);
  2. Number of clients to run;
  3. List of available scenes to execute;
  4. Edit button: loads this scene on Editor;
  5. Play As Server: run this scene on the Editor as Server.
  6. Debug Start: run the scene on the editor (if Server or Client is selected) and the number of clients as standalone.

Using this window, you can start a server and several clients at once and then have them all connect to each other and load the correct scene, without manually doing anything.

The button Play As Server starts the selected scene as a Bolt server, this gives a quick and easy way of testing features when developing. Below you can see the server running inside of the editor after pressing Play As Server.

play the scene as server
Play the Scene as Server.

The most useful option on the Bolt Scenes window can be found at the Debug Start button. By pressing it, Bolt will build, run and connect the number of clients signaled on the options, automagically. This is handy when you want to test your game on a multiplayer scenario but don't want to waste time preparing the clients, as this may need to be executed several time while developing the game. Below you can see the Debut Start in action:

running the game with 3 clients using the debug start
Running the game with 3 clients using the "Debug Start".

That was all for this chapter, in the next one we will start developing code for our game.

Next Chapter >>

Back to top