Hello I am trying to create a state manager that detects whether a player is attacking, blocking, rolling, etc.? What is the most optimal approach? I’ve heard attributes can be effective, but they can also be performance-intensive. Any ideas?
I do not recommend that, because what if the character dies while blocking? Then he spawns while blocking, because it is inside the player! Therefore I recommend making the value inside character, rather than inside player instance.
Attributes aren’t that performance intensive, unless you have like a 10.000 attributes!
I recommend sticking to using attributes, that are of the character (not the player), and using Attribute.AttributeChanged events to check if the attribute changed and do something with that. This is the best approach, because it is event-based and doesn’t require a loop! This is the simplest and best for performance way, therefore the best way in my view.
The attribute is automatically deleted on death, because the character itself is deleted when you respawn. So you don’t need to do anything. A script should check when a character is added and puts the attribute to the character.
I wasn’t asking a question lol, I was just saying, but sure, attributes might be better, I just use values because it’s just easier for me to understand what’s happening, and I can actually see the instance, rather than checking for attributes in the instance.