O'Reilly logo

Unity Game Development Scripting by Kyle D'Aoust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding items

Now, we'll create our first interaction with the inventory: adding items. This is probably the most important aspect of having an inventory. Why have an inventory that can't have items added to it?

Let's figure this out

Before we jump into the coding, let's take a moment and plan out how we want to add items to our inventory. From the player's point of view, adding items to their inventory is something as simple as placing the item in their bag, or walking into the object and having it appear in their inventory. What they do is similar to how we will add items. They see an empty slot in their inventory and then place their newly obtained item into that slot. We will be following a process similar to that within our code, creating an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required