This is a game I created for my C# scripting for engines in university
• Solo • 8 Weeks • Unity • C#
This top-down game was created in 8 Weeks throughout this modules lifetime. From this I learnt about how Unity's engine and C# work in conjunction to create a game from a framework with a basic player controller.
I wanted to expand my knowledge of grid based games, so I wanted to create a survival game with a grid building system. I also wanted to create an inventory system that would be used with this building system.
For my game I wanted to collect items throughout by destroying elements of the world. To do this I created a data table of sorts to add items to the game. I did this so it is easy for others to add items to the game without having to go into a json file or any file in general, and because it is easier with using engine files such as images.
A few placeable items are in the game and what they are, are prefabs that I can place around the map. I have a few collision boxes to check for collision if so it will change the materials colour to a red one if it's overlapping an item if not it will be green for you to be able to place that item. These items are selected from an interface that pops up when you hit the B key and can be destroyed when you open the bulldoze mode BACKSPACE. This mode does a box trace at the location of the cursor to world position to check if it is overlapping anything that can be destroyed if so it will delete it from the world.
For the placeable items there is also an overlay that shows when you get close to the item. This overlay will show what you need such as 10 wood or 8 sticks. This is all done with a tuple that has the number that is needed such as wood which is 1 and the amount that you want such as 10. This allows for modular set up. The UI shows up using the panel set to screen space mode so it follows the item rather than the whole screen.
The interaction for the items is a simple collision sphere that allows for you to walk up to the item from any angle and pick it up. To break down trees and rocks it does a line trace from the right of the object so you have to be looking at the item you want to break. This makes it feel like your character is in the action rather than you just clicking, and it breaks without your character looking at the item.
The inventory is split into two files, the inventory script and the inventory UI. When the inventory is updated the UI is refreshed to keep the items up to date. For the inventory they are just IDs which correlate with a data table to the item's name and image. This allows me to reference them without having hard references to them. In crafting I just have 3 & 1 = 9 which allows for a simpler modular backend.
I wanted the crafting to be like Terraria's crafting where if you go close to a placed crafting table a UI element pops up, and you can then click items you have enough resources to craft. This is great for quick time events as if you are in a hurry you can just click on an item and craft that.
The enemies are controlled by a single script which has a few states. One is to chase the player, another is to attack the player. Enemy slimes are spawned in at night so you need to kill them or sleep before they spawn. They are a crucial part to the game so you need to kill them before you can finish the game. This allows the slimes to be a mechanic rather than fluff. Enemies hit the player every 2 seconds they are in proximity to the player.
Simple World Gen.
My focus was not on the art assets and such. The world elements such as the tree and floor are from an asset pack but everything else from the items you place to the items you get and craft have been created by me in Aesprite. This was mainly due to the fact I wanted to learn a new program and workflow with Unity as I have not had the experience to do so in Unreal as much.
Price Loading...