The next stage of Project Venice is to introduce the graphical element. I'll be using Unity and their web client to do this. I want players to be able to see the game world and Unity makes this easy. It'll be an isometric view of the solar system. Nothing too complex to start with.
I will be using Socket.io to populate the Unity web client with data. This type of connection is open to everyone, so conceivably players could look at the game world without ever having to log in. I'll have to look into that idea later on.
On the Unity side, I am using UnitySocketIO, which provides a nice easy to use interface. When the client starts up, it requests the data for the current star system. The server grabs it from the database, as a JSON string, and sends it down to the client. The client then renders the planets based on the data.
To make the planets I am using a Unity store asset called Perlin Planets. It allows for the random generation of planets based on a seed value and some other options. The long term goal of Project Venice is to have an explorable galaxy, so being able to generate planets in a procedural way is very important. For the prototype, there will only be a few planets though.
One challenge I came across during implementation was that the UnitySocketIO library actually operates in a separate thread. Unity is not multi-threaded, so I can not interact with it from an outside thread. So when I receive data from the server, I can't just create the Unity objects.
To get around this, I put in a simple job system. The SocketIO side will queue up a job to create a planet, then the main Unity thread will pull it off the queue and do it. In my limited tests it seems to work fine. We will see if it scales up once I start adding starships to the mix.
Stolen Realm - Review
6 hours ago