Unity
Last updated
Last updated
Follow these steps to quickly set up and start using Planetary Processing with your Unity game. For more detailed information on both the SDK and the server-side API, please visit our .
We recommend using Unity’s most recent LTS release version. If you are using an older version, we recommend a minimum of 2022.3.23f1 for a successful integration.
Navigate to the
Click Create Game in the top right
Provide the details of your game. Upon its creation, you will be taken to your Game Dashboard.
For this quick start, we will be using Anonymous Auth, which allows players to connect without a username and password. To enable this, navigate to the settings section of your Game Dashboard and enable Anonymous Auth as the Player Authentication Type within Game Settings.
Create a new Unity project, from the Unity Hub.
Select the ‘Package Manager’ from the ‘Window’ tab in the topbar.
In the Package Manager, add the Planetary Processing package using the ‘Add package from git URL…’ option.
Input the following link, to install the Planetary Processing Unity SDK:
Create an empty GameObject. This will control which game server you connect to and sync the entities with the server.
Create a 3D GameObject to act as the player, such as a cube.
Navigate back to your cloned game repository.
Locate the ‘entity’ folder.
To quickly make a prefab from scratch:
Create a 3D GameObject, such as a sphere.
Select this GameObject in the hierarchy window, then drag and drop it into the assets window to automatically convert it into a prefab.
Delete any instances of the prefab from your scene.
Create a prefab for every Lua file in your game repo’s entity folder.
Connect your player GameObject (eg. a cube) into the ‘Player’ input.
Connect each of your prefabs to separate elements in the ‘Prefabs’ input list.
Your server connection object now has all the info it needs to pass to the server. Now we just need a script to connect/login.
Add a script to your server connection object.
Use the example function below to establish a server connection on start.
You now have everything you need to establish a basic connection between Unity and the server-side demo code.
Click Actions>Start Game to start the server-side simulation.
Launch your game from Unity.
In your Unity preview window, you should now be able to see the game world and all its entities. Your Planetary Processing game dashboard map should also show that a player has joined!
Basic player movement can use the regular Unity input system. However, rather than change the position of the player GameObject, instead send a message to the server-side entity, to update its position.
Make a movement script and add to it the player GameObject, with the code below as a guide.
Create a 'PPMasterTag' tag for the server connection object, for ease of reference.
You can also change how many and what entities are spawned in the init.lua file.
Go back to your game dashboard in our web panel
From the actions menu in the top right, stop the game if it's running.
Select "Deploy Latest Version" - this will roll out your updated server-side code.
Start up your game again in Unity and in the web panel, to see the changes you have made!
Clone the repository as listed in your game dashboard - this is your Planetary Processing backend code.
The Unity SDK provides two new components which can be added to GameObjects. These are and . These can be accessed in the 'Add Component' menu of any GameObject under the PP heading.
Add the component to this GameObject.
The component will need to know three things: which object is the player, which prefabs represent the other players/entities, and the Game ID of the server.
Add the component to this GameObject.
The component identifies entities in the game world. The main player character is the only entity which uses the component but does not use a specific 'Type' on the clientside.
Entities populate your game world. Every Entity has a ‘Type’. These are defined in the backend code downloaded from your game repository.
Make note of the names of the .lua files inside the ‘entity’ folder. These are your .
For the demo game repository, the : cat, tree, and player are used. The ‘player’ type is for representing other players in the game. It is also used for the main character's server backend, but remember the main character's Type must remain empty.
Entities in Unity are formed from prefabs with the component and a Type parameter. To make an Entity, download or create a prefab, then edit it to have the component and a Type matching a Lua file.
Add the component and input its Type. Entering ‘cat’ will sync this prefab with the ‘cat.lua’ entity in the server-side code.
Return to the empty GameObject you created first, with the component, and start filling in its parameters.
Enter the Game ID of your game. This is a number which can be found on your , next to your game’s name and repo link.
On the Planetary Processing , select your game to enter its dashboard.
Make sure the player object's node has its 'Use server Position' value ticked (it is by default).
Using the we cloned earlier you can edit the behaviour of entities by changing their Lua file within the ‘entity’ directory.
We recommend here to get a sense of what you can do with Planetary Processing. When you add or change entities, make sure your server-side changes match up with your game engine client.
After configuring your game entities and logic, to the game repository:
If you have encountered any issues, we have a premade demo of this guide: If you have further questions, please get in touch on our .