If you dream of a better society, a computer game about the reality of urban poverty and homelessness is just for you. It not only raising awareness of street life, but provides the opportunity for people to be a game content creator, at least for a day thanks to Unity3D.
The survival game is called Hard Times and was created by Ivan Preziosi. He presented a talk this year at Codemotion Rome, about the Data Driven Modding paradigm and how his game was created with Unity 3D.
The Opportunity of Developing With Unity3D
Unity3D is a complete IDE engine, a development environment, that you can try for free and is available for both MacOS and Windows. It can deliver builds for all of the most popular gaming platforms.
Hard Times is an urban survival computer game, where we are put in a homeless person’s shoes facing the brutal challenges of daily survival, made worse by an indifferent society and the frenetic pace of business life. The game invites us to reflect on the marginalization of poverty and feeling of indifference experienced by the homeless.
Ivan describes himself as a “hobbyist”, but he aims high, bringing his game beyond the borders of Italy. He participates in many gaming events, arousing the interest of local institutions. He has created a game with a strong social message, effective retro style graphics, and the possibility of future game extensions.
The Architecture
How can we become a game content creator? The secret is in how the game flow will be influenced by the data layer. Ivan chose the Data Driven Paradigm to model the game flow with a benefit: simplicity.
This allows us to modify and extend to the game only by writing some text file in a format: JSON.
A paradigm can be described as a set of patterns and methods that are commonly accepted by members of a scientific community.
Hard Times was envisioned from the beginning as a core moddable engine running a base default mod, called “Vanilla” representing the base default gameplay. This structure was designed to make possible the easy addition of more user generated content, in the form of additional mod packages. Entities’ behaviour and properties are then described using a relational data structure created on top of a JSON file structure.
JSON is a human-readable data format that is used very much in REST architectures for exchanging data between services that use the Internet.
The Value of Data-Driven Modding
At Codemotion Rome 2019 Ivan demonstrated how the game could be extended, with customisable content thanks to modding by anyyone, even if you aren’t an expert. He offered some insights into Data-Driven Modding, noting it is not his intention to get into the complexity of unnecessary software architectures.
The next step is the Functional-Driven Modding. Here, the game modifications are more complex than previously, because you have to get some minimum requirements, such as knowledge of some scripting language (JavaScript, LUA, C, etc.).
Data Driven Programming is a paradigm software architecture where the data control the flow of the business logic, only by changing the data-layer without touching the source code.
Hard Times wants a society to be accessible to everyone regardless of money, gender or ability. Ivan wants a modding system more usable by the players and to transform them into creators of the game itself. Thanks to these design choices we get:
● EASY TO IMPLEMENT: short, strategic steps;
● SECURITY: the possibility of injecting malicious logic into the source code is avoided ;
● USE: changing or adding original content to the game is a simple operation without the need for advanced technical skills;
● ZERO ENVIRONMENT: the system is based on .json, .png and .ogg files, a notepad and free editors like Gimp or Audacity are enough;
● DISTRIBUTION: mods are auto contained in a zip.
Implementation
Hard Times uses the Full Serializer library, a more powerful tool than the built-in serializer code in C#.
In Ivan’s design, each game entity which has an effect on our player stats is mediated by a “player effect”, a json described entity, who will directly affect character’s stats, such as stamina, life, hunger or smell. This makes it possible to extend and create new player effects in order to modify the behaviour of any given game entity.
To create a change, we must respect the conventions of the structure of our folders, files and JSON themselves.
Each object has an “id” (identification like relation id table) reference just like an entity of a relational database, allowing us to define game mechanics and relationships between all the various game entities.
The various entities of the game (items, furniture, doors, scenes, etc.) each have a Manager class that will handle the creation and modification of the relevant data structure (resembling the organisation of tables in a database).
Data loading order is important due to Hard Times’ additive approach, where the data contained in the JSON – when possible – is merged with that previously loaded.
For game dynamics in which control must be predictable and not lead to anomalies, such as the control of weather, Ivan instead opted for the substitute approach. In this case, we would not have an additive behaviour, but a complete replacement of the properties.
The Steps to Publishing
Mods publishing and distribution, between creators and users, need an appropriate platform. There are various free solutions for the distribution of your code, each with their own characteristics and potential pitfalls (such as the security of the uploaded material).
While more tailored adhoc solutions are possible, they require time, money and extensive experience to manage problems related to:
- Security;
- API additions;
- Data processing.
With limited resources and time, you should rely on a mod repository service such as:
- Steam;
- Mod.io;
- ModDB.
In conclusion, with thoughtful design and software choices, it is possible to create easily moddable video games using Unity3D, which enjoy an extended lifespan, a more active and committed community and the possibility to benefit from final users’ creativity and talent, providing a creative and rewarding experience which goes far from the simple work initially developed by the game creator.
Hard Times was selected as an Indie Prize Finalist at Codemotion Rome 2019 and earned a dev scholarship to fly to the GameDaily Connect 2019 in Los Angeles to showcase among other finalists from all over the world.