Best way to set Player States

Hey, I’m currently restructuring my game and was wondering how I should set the player states. Let’s check this with an example. Let’s say I have a player who can be stunned and dodge, but he can’t dodge when he is stunned. I will need a way to let the player know that he is stunned. I’ve seen a bunch of approaches that all handle it differently. I’ve seen devs add attributes to the character or even add a new value to the character and save it there. Others just make their own module script. So I was wondering, what’s the best possible approach?

1 Like

I would recommend a Player object that keeps track of these states using lua oop. Though, there is nothing wrong with using attributes / values.

1 Like

How would you go about creating one?

1 Like

Maybe not a class for each player but a standard module instead? It might be easier to keep track of each player without worrying about memory leaks when they leave, etc.

I helped someone else with a similar issue, it might help you.

1 Like

Modules are generally the superior way to go about health and character states.