How should I use my PlayerState compared to Character/Components?
I'm making an RPG where I need stuff like health, stamina, mana and levels, experience, faction, etc. So I was wondering, in which class should I store the various variables? In a PlayerState or Character/ActorComponent?
Currently I'm having health, stamina, etc. in the character and levels, experience, etc. in the playerstate. But I'm not sure if this is the best way to go. Do you have certain rules for what types of stuff goes where? What about inventories and skillpoints(points spent in various skills)?
Hope this was understandable, and thanks in advance! :) Greetings, Stefan
asked Apr 23 '19 at 06:58 PM in C++ Programming
When deciding how to implement these things I usually ask myself "Is this something that I'll want to use across multiple character / object types". If the answer is yes (and more often than not it is), then I'll make it a component.
However, if it's something that very fundamental or lightweight, I might put it in some base class which I'll then inherit from (e.g. AEnemy, which I then use to create AEnemyMonster, AEnemyTurret etc).
To me, one of the big benefits of components is I find they help keep your code maintainable and potentally portable to other projects.
answered Apr 25 '19 at 08:55 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here