• Item Creation Tool

  • Interaction System

  • Save System

WHAT I WORKED ON

Role:

Systems Programmer

Language:

C#

Engine:

Unity 6

Team Size:

14

Project Duration:

4 weeks

Botanica

  • Botanica is a first person horror game where you perform night duties as a caretaker in a greenhouse, and eventually you try to escape from a monster that doesn't move when you look at it.


  • The player can interact with objects in the world in different ways. Examples include picking up and dropping objects, interacting with objects using input prompts and others.


OVERVIEW

  • Since the game has a lot of pickable items, I decided to program an easy-to-use item creation tool so that designers could easily create items and place them in the world.


  • The intuition was that all the designers would have to do is create an item through the tool by typing in some details, and after the push of a button, an item prefab with all the necessary components would be created, and any instance of that item placed in the world would also be traced by the save system.



ITEM CREATION TOOL

(C#) Creation and Destruction of Item in Item Tool

    private void GenerateItem()
    {
        //Creating a Default Empty Prefab
        GameObject emptyItemPrefab = PrefabUtility.LoadPrefabContents(EMPTYITEM_PREFAB_FOLDER_PATH);
        GameObject newlyCreatedItemPrefab = PrefabUtility.SaveAsPrefabAsset(emptyItemPrefab,
            ITEM_PREFAB_FOLDER_PATH + _itemNameField.value + ".prefab");
        
        //Grabbing the ItemInfo component which is used as runtime data
        CS_ItemInfo newlyCreatedItemInfo = newlyCreatedItemPrefab.GetComponent<CS_ItemInfo>();
        
        //ItemData contains an ID that is used by the save system to save the item
        CS_ItemData newlyCreatedItemData = new CS_ItemData();
        newlyCreatedItemData.ItemID = (ushort)_itemDataScriptableObject.ItemDataList.Count;
        newlyCreatedItemInfo.ItemID = newlyCreatedItemData.ItemID;
        
        //Per item data
        newlyCreatedItemPrefab.layer = LayerMask.NameToLayer("Item");
        Enum.TryParse(_itemTypeDropdownField.value, out CS_ItemType itemType);
        newlyCreatedItemInfo.ItemType = itemType;
        
        //Registering data of newly created item in a scriptable object that stores item data
        newlyCreatedItemData.ItemObject = newlyCreatedItemPrefab.GetComponent<CS_Item>();
        newlyCreatedItemData.ItemObject.ItemInfo = newlyCreatedItemInfo;
        _itemDataScriptableObject.ItemDataList.Add(newlyCreatedItemData);
    }

    private void RemoveItem()
    {
        AssetDatabase.MoveAssetToTrash(
            AssetDatabase.GetAssetPath(_itemPrefabsList[_itemListView.selectedIndex]));
        AssetDatabase.MoveAssetToTrash(
            AssetDatabase.GetAssetPath(_itemPrefabsList[_itemListView.selectedIndex]));
        RefreshItemDataList

  • I decided to make a customizable input prompt scriptable object that would contain a variable list of prompts. This was so that designers could make input prompts for interactions quickly and easily.



INTERACTION SYSTEM

  • It was decided that the game would have a prompt-based interaction system where the player would input keys in a particular order to interact with certain objects in the world.



  • The save system I made for the game was relatively simple. After referring to some resources online about how to architect a save system, I decided to have two main components to my save system - A File Data Handler and a Data Persistence Manager.


  • For the File Data Handler, I used Unity's inbuilt JSONUtility to store data in a save file in JSON format as well as read data from a save data from a file.


  • I created a Game Data Container class that stored the entire game state. This would include sub-container classes that hold the world-state data.


  • The Data Persistence Manager would use the File Data Handler to load save data and use that to change the world state of the game. For saving, it would grab data from data container objects for gameobjects that need to be saved and pass it as data to the File Data Handler.



SAVE SYSTEM

gaurdian.kiran@gmail.com

+46 769666977

Contact: