Making a Hack’n’slash #7: Using Scriptable Objects and Prefabs

Let’s improve our Hack’n’slash data organisation!

Mina Pêcheux
CodeX
Published in
7 min readMay 12, 2022

--

⬅️ Tutorial #6: Hitting enemies | TOC | Tutorial #8: Implementing a basic AI using a Finite State Machine 1/2 ➡️

In the last episodes, we worked on our hero/enemy interactions. In particular, we set up a basic multi-hits combo system so that our player can hit the enemy and eventually kill it.

But, for now, we’ve directly initialised arbitrary values for the attack range, the healthpoints, etc. in our manager scripts… and we’re beginning to have quite a lot of components here and there on our game objects (plus some nested hierarchies). The problem is that although all of this is quick to implement, it’s not very reliable.

For example, as we start to add more parameters (like an attack rate, the attack damage…), it will start to crowd our manager scripts with lots of variables. And if we want to have several enemy types with different amounts of healthpoints, it will soon become pretty hard to configure. And if we create another “Brute” enemy, we’ll have to make sure to re-create the proper hierarchy and link everything up.

That’s definitely not robust enough for our game!

--

--

Mina Pêcheux
CodeX
Writer for

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 :)