Video was a required field so I put in a quick YouTube link :) as the presentation tonight will feature the demo itself
Introducing the Game Engine Bridge
For this Hackathon I created a prototype of a GameEngineBridge which allows for 'easy' use of the Unity Game Engine inside your DApp. Technically the pattern would also allow for GoDot or Unreal Engine but the implementation needs to be adapted a bit for each engine. The core idea is that the DApp is responsible for reading data from World API & Blockchain and starting transactions on your smart contracts. The game engine and DApp can communicate through an event bridge which sounds more complicated than it is, both are just sending messages to each other over the browser window.
A small 'game' as a prototype
For the game part (which for now I call Project Eidolon) I reused/modified some components I started a few years ago when I was learning Unity where a procedural planet is created and simulated over time. For the Hackathon it will generate a planet based on the current solar system, and x y z coordinates of an SSU and based on that determine a seed for planet generation & simulation. The X, Y, Z needs to change an order of magnitude to trigger a seed change and thus different planets are generated depending on where you are in the solar system. Also ensuring the same players see the same planets if they are in a similiar location.
Planets change over time!
As the blockchain develops (last transactions) the simulation system starts to tick and process population increases and decreases (in a real situation it would simulate probably 20 / 30 different planet stats similar to say a city in Civilization). All of this is deterministic (but random per planet) so it can be replayed for any state of the blockchain with consistent results. Ensuring that everyone sees the same planet state at the same location.
The tick system performs a lot better than I expected and it can generate a lot of ticks quickly at the moment with the limited data that needs to be calculated. That being said if you would have this run for a long while and the blocks on the chain keeps growing you would eventually end up with a very slow starting Unity Project due to generating 100,000 ticks.
What I didn't do (yet)
The solution for constantly recalculating the entire timeline of a planet would be a snapshot system where when players interact with planets we save out the random state and a snapshot of the data of the planet to a mud table to basically create a ‘save’ point in the planets timeline and start the render from that point in time again on the next visit. I currently did not have time to implement this.
I also had intended to add a player event (mud) table which allows players to add events to planets to hook into this deterministic cycle and have control (or compete) over planets with actions such as "give food", "cause disaster", "build house" but I also won't have the time for that other than the mud design part. However I did want to prototype some form of player control / action on the game so I added a really simple discovery feature where in Unity you trigger a smart contract transaction through your DApp.
If this all sounds super complicated and you are maybe familiar with event sourcing the entire planet state is one big event source like system of ticks and player events being combined
Play around with it! Live demo!
All of this is now 'live' on this URL if you have meta mask or EVE Vault setup for stillness or nova: https://eidolon.horde-square.com/ (its currently hardcoded to get information from Nova but your stillness account will work). And live in-game on 2 SSU's on the Nova server in U.G0S.RB8 at the Keep & P7L5 [L-Point] if you are setup with Nova access for the Hackathon.
I'll also demo it live on the presentations tonight.
Instructions for demo
- https://eidolon.horde-square.com/ in a browser setup with Meta Mask or EVE Vault.
- There is currently 0 error handling or hand holding so if you don't have Meta Mask or EVE Vault setup you will just crash out :D. (Sorry lack of time for polish)
- Since you are in a browser and not an SSU it will hardcode an SSU for demo purposes for you.
- You can now see a planet generated and simulate population over time (every 100 blocks)
- If you enable debug mode you can manipulate the X, Y, Z and Solar System to see different planets.
- You can discover planets by using the discover button, this will start a transaction.
At the moment there are 5 planet biomes: gas, lava, desert, terran and ice some are more rare than others and most planets have some little props placed on them as well.
Full presentation with technical details:
https://docs.google.com/presentation/d/1QFf_20KWMxJX-LjKpLpm90HWgi9By7JLWI4qEmYAp4Q/edit?usp=sharing
Built With
- amazon-web-services
- angular.js
- cloudfront
- s3
- solidity
- unity
Log in or sign up for Devpost to join the conversation.