Overview of Reactor
Summary
This is an overview of common terms, services, and capabilities of the Reactor mulitplayer game system. This tutorial covers installation and basic usage of Reactor. It contains information on setting up, project structure, and the common keyboard commands.
What is Reactor
Reactor is a multiplayer system that allows developers to quickly program, publish and manage mulitplayer game servers. A developer starts by downloading the Reactor unity package and importing it into an existing or new Unity project. The package includes:
- Components to design and configure rooms, scenes, and server entities.
- APIs for writing server and client scripts.
- Interfaces for publishing and launching test instances.
- A limited local server for rapid prototyping.
Requirements
- Windows 10 or 11
- Unity 2020.3 or Unity 2021.3
- .Net Framework 4.8
- Visual Studio or Rider
- Reactor Multiplayer Unity package
- A KinematicSoup account with access to a Reactor project
Setup
Reactor is distributed as a tarball file which requires the Unity package manager. See https://docs.unity3d.com/Manual/upm-ui-tarball.html
Project Layout
- Project/Assets/ReactorScripts/
- Common/ Scripts common to Reactor servers and clients.
- Client/ Location for Reactor client scripts created through the 'Add Component->Reactor' menu.
- Server/ Reactor server runtime project and scripts.
- Proxies/ Proxy scripts used to map servers scripts to Unity components.
- Resources/ Configuration and server/client asset mapping.
- Project/KinematicSoup/Reactor/ Location of a local server for this project.
- image/ Server image files.
- intermediate/ Intermediate image build files.
- logs/ Local server logs
- server/ Local server files
Server scripts and common scripts (shared by the client and server) must be in a server or common folder. You can use the default common and server folders, or create your own common and server folders. To create a common or server folder, first create the folder. Then right-click in that folder in the project browser and select 'Create->Assembly Defintion Reference'. In the inspector for the assembly reference, set 'Assembly Defintion' to 'KSScripts-Common' for a common folder and 'KSScripts-Server' for a server folder. All scripts placed in this folder or any subfolders will be common or server scripts. If a subfolder contains another assembly definition or assembly reference for a different assembly, scripts in that folder will not be common or server scripts.
Note that server scripts and common scripts cannot contain any Unity references.
Terms
Server
A remote application that accepts client connections and runs game logic.
Client
A local application that connects to a server and renders game state for a user.
Room
A set of configurations and scripts associated with a scene that controls multiplayer game logic.
Entity
A mulitplayer object that syncs its state from the server to connected clients.
Player
An instance of a client connected to a server.
Scene
An environment containing entity data that forms the basis for a room.
Image
A collection of published rooms and scenes files containing server logic used by a server instance.
Instance
A game server running a room and scene using scripts loaded from a published image.
Cluster
A group of running instances that have the ability to message and share property state with each other.
Sever Runtime
An assembly compiled by Reactor during publishing that includes all scripts required to launch instances.
Server Room Script
A script component attached to a room whose behaviours are only run on the server.
Server Entity Script
A script component attached to entities whose behaviours are only run on the server.
Server Player Script
A script component attached to players whose behaviours are only run on the server.
Client Room Script
A script component attached to a room whose behaviours are only run on clients.
Client Entity Script
A script component attached to entities whose behaviours are only run on clients.
Player Controller
A script that interprets user inputs to control an entity.
Remote Procedure Call (RPC)
A function that can be invoked on a remote server or client.
Property (Entity / Room / Player)
A piece of data that is associated with an entity, room, or player and is synced from servers to clients.
Transform (Entity)
A collection of data that represents an entity's position, orientation and scale in the game and is synced from servers to clients.
Unity UI
Settings
Reactor settings can be accessed from the 'Menu Bar->Reactor->Settings' menu and can be changed in the inspector. The 'Server' section defines the build rules for the server runtime.
- Define Symbols allows you to set preprocessor defines for the Server Runtime.
- Override Server Path is an optional property which can be used to set an explicit path to a local Reactor server location. If this value is blank, the server in Project/KinematicSoup/Reactor/server/ will be used.
- Build Tool Path is the executable path of the C# compiler.
- Log History Size is the number of log files the local server will track before removing old logs.
- Restart On Update will cause local server instances to restart when there is an update to the ksServerRuntime or configs.
- Auto Rebuild Server will automatically rebuild the server runtime when changes to server scripts are detected and Unity compiles.
- CheckServerFiles will check the local server installation and prompt to download a version compatible with the installed Reactor package.
The 'Build' section contains configuration data for the published image which the Reactor client code uses to find and connect to instances of the same image.
- Version The server version that the Server Runtime was built against.
- Image Binding Unique identifier for your published image.
- API Key Unique ID that identifies the project in the player APIs.
- API Client Secret Authentication token used by clients to access the player API.
- API Server Secret Authentication token used by server to access the player API.
The 'Debug' section contains debug settings for Reactor entities
- Default Server Ghost Color Sets the is the default color of all entity ghosts.
- Default Server Ghost Material Allows an override of the material used to render entity ghosts.
Collision Groups allows you to assign names to the collision groups used by collision filter scripts.
Building
This tutorial requires you to publish or build your project after making changes to server scripts or configurations. You can also find these under the 'Menu Bar->Reactor' menu. The shortcut keys are provided.
- Build Scene Configs (CTRL+F2) to build configuration changes in modified scenes for the local server. You should build scene configs after adding, removing, or editing Reactor components such as KSRoomType, KSEntityComponent, or server scripts.
- Build KSServerRuntime (CTRL+F3) to rebuild the local Server Runtime. The built assembly contains all of the server scripts you write. You will rarely need to use this shortcut as the Reactor editor code will detect changes to server scripts and rebuild the local Server Runtime automatically.
- Rebuild All (CTRL+F4) to rebuild the local Server Runtime and build configurations for all scenes in your project for the local server.