Making a RTS game #5: Transforming our data into Scriptable Objects (Unity/C#)

Let’s continue our RTS game project by exploring Unity’s Scriptable Objects!

Mina Pêcheux
CodeX

--

⬅️ Tutorial #4: Selecting units | TOC | Tutorial #6: Improving the UI ➡️

📕 Get the ebook and bonus material on Gumroad!
🚀 Find the code of this tutorial series on my Github!

Today, we’re going to see how to store data into Scriptable Objects, rather than defining them directly in our scripts.

At the moment, our data is defined in our global variables — and those global variables are of two types:

  • some are “external” data that we want the game to be aware of and use during the loading phase when it starts
  • others are utilities shared across of all scripts and internal to the game logic

The second type of variables should stay as is — there is no point in loading the reference to the “Terrain” layer from an external data source, for example. On the other hand, our building types could be loaded from another source: they are not determined by the game state. The list of in-game resources is somewhere in-between: though the notion of “gold”, “wood” and “stone” as resources could be loaded up, remember that our…

--

--

Mina Pêcheux
CodeX

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)