[Tutorial] Flexible Buff System with Scriptable Objects

Hey guys, wrote a small tutorial showing how one could use scriptable objects to create a pretty flexible buff system. There’s just two required classes, the buff scriptable object to hold the data and a buff logic class that acts as the timer and logic controller. There’s a third ‘BuffableEntity’ component that can be added to game objects that can receive buffs. I have found this method of a buff system to be very easy to use and flexible, especially when creating different buffs that vary only in value or visuals, while the logic remains the same.

It’s a text tutorial, you can read it here, or see the files on github here.

Any comments are appreciated, would love to hear tips on how I can improve this.

1 Like

My only problem, is that you present every single class in a complete form from the start. This encourages copy-pasting and the tutorial part of the whole thing is gone. I prefer having a sortof build up thing in tutorials, like, what does a buff need? of course, a timer and an initializer, but how do I do the latter? of course, I just return a new TimedBuff, and takes in the gameobject it affects. So let’s create that class and fill it

1 Like

Thanks, that’s a good idea. I will keep that in mind for next tutorial. Should be helpful for people to know the thought process behind things.

Long time since the last updated. Added two small but highly requested features:

  • Effect stacking: determines whether the buff value is stacked on each application
  • Duration stacking: determines whether the buff duration is increased on each application

Updated the tutorial and github repo to reflect the changes. Happy to make more updates if anyone has additional requests!

2 Likes