Godot
Introduction
Planetary processing is a platform for the creation and operation of multiplayer games; we provide a plugin for integrating our platform with the Godot Engine. The plugin provides nodes and signals to use within your game client code - these communicate changes in state from your server side simulation to the game client itself.
If you are new here, we recommend starting with the Godot Quickstart Guide.
Pre-requisites
Godot Engine v4.2.1+ .NET version required
.NET SDK 6.0+ (Desktop target)
.NET SDK 7.0+ (Android target)
.NET SDK 8.0+ (iOS target)
Installation
Clone the Planetary Processing Godot plugin from GitHub.
Create the addons directory in your project if it does not exist
Place the planetary_processing directory in the addons directory
Enable the Planetary Processing plugin via the Godot project settings
If not already setup on your project, you must trigger the creation of the C# solution via the Godot toolbar menu. This creates a .csproj and a .sln file in the root of your project.
Finally, we need to add a reference to the Planetary Processing C# SDK DLL to our .csproj file. This can either be done manually, or via the button in the PPRootNode inspector. To add manually, please ensure the following reference is added to your ItemGroup in your .csproj file
Custom Nodes
Before reading this documentation, we recommend you are familiar with the Conceptual Documentation for Planetary Processing.
Once the Planetary Processing plugin is enabled, two custom nodes are made available to your project:
PPRootNode
The Planetary Processing Root Node (PPRootNode) handles connections to your game backend, when running your game, while also enabling some additional functionality in the Godot editor.
If you have already added the "Planetary" reference to your csproj file, then the Add Csproj Reference button will not be visible. If it is present, you can click the button to have the plugin automatically add the reference to your .csproj file.
To configure your game, you must fill in the fields in the inspector:
Game ID - available in the Planetary Processing Panel
Variables
The root node exposes the following useful variables
Methods
The root node exposes functions you can use to communicate with the server side game simulation.
Signals
The root node emits signals which you can use to manage the lifecycle of entities.
PPEntityNode
The Planetary Processing Entity Node (PPEntityNode) describes a Planetary Processing Entity. This node is designed to be attached directly to the root node of a scene in your Godot project, this scene can then be instantiated as a child of your main scene. For example, a tree scene will correlate with a tree entity in your Planetary Processing game, and can have instances placed within your main scene.
The type field correlate with the server side Entity type.
Signals
The entity node emits signals which you can used to react to changes in the state of an entity.
Usage
The Planetary Processing Plugin has an intended pattern of usage:
You may log a player in using the authenticate_player method on the PPRootNode. After logging a player in, the custom nodes will begin emitting signals.
For the player who has just logged in, the PPRootNode will emit a new_player_entity signal. This signal is specific to the player running this instance of the game client. You can hook into this signal and instantiate your player scene accordingly. An example handler for this signal would be:
Note in the above that a PPEntityNode requires its entity_id to be set after instantiation, so that the node knows which signals to filter out and re-emit.
The PPRootNode will emit a new_entity signal for any entities that have not yet been seen by the game client. As an example, after logging in the PPRootNode will emit a new_entity signal for other players in the game world, as well as tree entities. These scenes can then be instantiated and added to the tree, representing other players and trees.
If any entities have left the simulation, the PPRootNode will emit a remove_entity signal. This signal can be used as a trigger to remove any scenes that are no longer needed from your tree. An example handler for this signal would be:
Each PPEntityNode will emit a state_changed signal each frame, provided they are still part of the simulation. You can use these signals to trigger changes to your scenes as necessary, for example, moving player characters around the world. A simple example of how this might be handled in a script attached to the scene representing other players:
You can send regular updates from the player to the simulation using the message function on the PPRootNode. These messages allow the player to interact with the simulation. It is up to you what data you want to send and how to process it in your server side lua code. Depending on your game, you might choose to send updates every frame, or on a fixed time delta, for example every 33ms.
An example sending the updated player position every frame
Your corresponding player.lua file may look like the following
It is important to note that the coordinate systems for 3 dimensional Godot games uses Y for height and Z for depth. Planetary Processing uses Y for depth in 3 dimensional games, and Z for height. As a result, coordinate values for 3 dimensional games need translating as seen in the above examples.
Last updated