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 starting building your version of the same game. Before we get started with the tutorial, open up the Bolt Settings window which you can find at Window/Bolt/Settings in the top menu.
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.
Your folder structure should look like this.
Inside the bolt_samples/AdvancedTutorial/scenes folder there is a preexisting level 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 bolt_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.
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 do this. Create a new scene called Menu into your tutorial/scenes folder and open it; on the Main Camera object attach the script found in bolt_sample/BoltInit.cs, as shown below.
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.
Click the Player Settings... button in the Build Settings window. Under Settings for PC, Mac & Linux Standalone verify that you have the following settings correct.
- Default Is Full Screen - DISABLED
- Default Screen Width - 640
- Default Screen Height - 360
- Run In Background - ENABLED
- Display Resolution Dialog - DISABLED
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 Assets/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 you have done on the Overview document. 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.
Testing Bolt: The Quick Way
Now you have the base to build your game and would be interesting to see this already working with a bunch of clients, right ? 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.
Let's look at another way to start our game, which is especially handy when we need to do quick testing. Open up the Windows/Bolt/Scenes menu, it will show a window that looks something like this.
Bolt Scenes description:
- Server port selection;
- Type of player to run on the Editor (None, Server, Client);
- Number of clients to run;
- List of available scenes to execute;
- Load this scene on Editor;
- Run this scene as Server;
- 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. To learn more about it watch this video.
The button Play As Server as expected simply starts the scene you click on as a Bolt server and since it's easy to setup your game with Bolt so that you can switch between dedicated or listen servers, 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.
Setting Up Our Layers
One last thing we need to do before we continue is to setup the correct Layers which we will be using later on. Open up the Edit/Project Settings/Tags and Layers settings. Make sure your layer settings match the following ones:
That was all for this chapter, in the next one we will start developing code for our game.