Where do player stat equations go?
Really dumb question but where do the equations for a player's stats go? Is it just tied to the setter? Say for example I have Attack Speed stat that has a Base of 1x and a Modifier of +20%. The final attack speed would simply be 1 + 0.2 = 1.2x speed. Would I have a third variable AttackSpeedFinal that gets set whenever AttackSpeedBase OR AttackSpeedModifier gets changed?
asked Feb 09 '18 at 09:04 PM in Blueprint Scripting
You could do that or you could do the calculation on demand (when you need the final value). If it's not too complex and not running every tick, it shouldn't put too much of a load on the CPU.
To calculate it once and use the result on demand, create a function that sets each stat rather than setting the variables directly. There you can also add functionality that updates any dependent variables using the calculation. Then you can set a stat from anywhere and be sure the final calculations will be correct.
Follow this question
Once you sign in you will be able to subscribe for any updates here