Filip Jerga
September 13, 2021

The Complete Unity Guide 3D- Beginner to RPG Game Dev in C#

New to Unity and raring to learn more? Well, we’ve got just the right project to kickstart your journey.

TODO: provide alt

Unity is an all-purpose game engine that supports both 2D and 3D graphics, as well as scripting through C#, and the drag and drop functionality. Developed by Unity technologies, it’s by far the most popular game engine on the block today. Its vast suite of built-in features including 3D rendering, physics, and collision detection help Unity seal its reputation as a formidable tool, making it the preferred choice of developers in the process.

Despite its convenience, however, beginners often have a hard time selecting a project with which to set sail on their Unity journeys. If that’s the case with you as well, then this video — The Complete Unity Guide 3D- Beginner to RPG Game Dev in C# by Eincode — is just what you need. This all-new video lecture discusses and demonstrates in detail the process of building a simple pickup system from scratch. You’re advised to code along with the video to acquire a greater grip on the following discussion.

Full Course


Understanding The Scope Of The Project

In this article, we’ll discuss the working of a pickup system wherein the player will interact and collect the objects in their vicinity. In the process, we’ll also create an inventory system that stores the details of every collected object. A preliminary demonstration of the game has been done in [0:12] of the video.

At [0:35] of the video, you will be able to notice the presence of a “Use Item” button in the Unity IDE. The purpose of this button is to spawn the items that are collected by the player. Every object that is spawned is subsequently emptied from the inventory. The link to the GitHub repository containing the code for the initial project discussed in this article has been provided in the description of the video. To understand how to go about this, refer to [1:00] of the video. For this project, the code editor we’ll be using is Visual Studio.

Getting Started

Once you download or clone the project from the Github repository, you’ll straight away be transported to the scene of the pickup system. If the scene fails to open from you, then [1:45] of the video discusses an alternative method for accessing the same. Once the scene opens on your Unity IDE, we can proceed with the following steps.

  1. First up, we need to create a representation of the pickup. To do that, you need to go to the hierarchy column of the project window and create a 3D object. [1:56] of the video demonstrates this.
  2. Next, we need to define the position and scale of the object under the transform column. To understand how to do this, refer to [2:18] of the video.
  3. This object will now act as our pickup object. [2:35] of the video explains how you can create a script to call this pickup object.
  4. Next, we need to configure our pickup script. Refer to [3:11] of the video to understand this process in detail.
  5. To distinguish your pickup object from your surroundings, you may impart a colour of your choice to it. [4:57] of the video explains how you can do so.

Interacting With The Pickup Object

Now that the pickup object has been introduced into the scene, we need to understand how to interact with it. This has been covered in [5:47] of the video. The following points discuss the same.

  1. To interact with the pickup, we need to add to the pickup box collider so that we can trigger some events on it.
  2. Pickup colliders must be set to “Trigger” so that we can walk over.
  3. The best way of going about this is to write a script on the character to handle the OnTriggerEnter event. Section [5:57] of the video demonstrates this in detail.
  4. If you wish to interact at a bigger distance with the pickup, then you need to increase the box collider. Alternatively, you can also decrease this range as per your requirement. To gain greater clarity on this step, refer to [6:00] of the video.
  5. To understand how to specify the OnTriggerEnter method you can navigate to [6:47] of the video.
  6. Next, you need to ensure that only your player collides with the created game object. [7:32] of the video explains how you can go about it.

Creating Items

Next, we’ll talk about how we can create a few fake items that’ll be collected by our player and eventually reflect in their inventory. Section [9:05] of the video covers this in detail.

  1. Create a 3D object under the project hierarchy column using the same process as was discussed above.
  2. Position and scale them as per your requirements. [9:31] of the video elaborates on this.
  3. Create a prefab so that we can reuse all of these items at a future instance of this project. To understand how to create a prefab, refer to [10:38] of the video.

Creating an Inventory Object

Now that we have created the items that our player can interact with, we need to create an inventory object that will keep track of each item that our player collects. Section [14:54] of the video talks about this at length. The salient points are listed below.

  1. Inventory will be created as a scriptable object so that we can persist the data.
  2. A scriptable object is similar to a game object except that they lack the transform property.
  3. To understand how to create a scriptable object in the coding editor, refer to [15:25]of the video.
  4. Keep in mind the fact that the inventory will only contain the names of the items.
  5. Next, refer to [21:59] of the video to understand how to emit an event as we are picking up the item. This will enable us to listen to this event on the player so that we can add this item to inventory.
  6. Incorporating a couple of more improvements as discussed in [25:34] of the video helps you achieve the desired outcome.
  7. If instead of a persistent inventory, you want to keep a removable one, navigate to [26:33] of the video.
  8. To complete this process, you need to instantiate the items (aka, the “Use Item” button that we saw at the beginning of the video) as you’re picking them up. [28:24] of the video guides you on the same.

Wrapping Up

Once the inventory is created, you need to work on a couple of concluding functionalities to wrap up this project. Watch from [32:08] of the video to acquire an elaborate understanding of the same.

This concludes our discussion of the creation of a simple pickup system using the Unity IDE.

Looking for More?

If you found this project interesting and want to work on similar ones in the future then you should consider taking up The Complete Unity Guide 3D- Beginner to RPG Game Dev in C# course offered by Eincode. Curated by experienced software engineer and freelance developer Filip Jerga, this course starts with the fundamentals and progresses gradually to eventually take its subscribers through the journey of developing their own RPG game by using Unity 2020 and C#.