How performant are attributes, should they be used for constantly changing values? are value objects better for that purpose? Or should I just stay away from the instances entirely and code a module that can hold that value?
Context: I’m making a mode switching system (e.g: “press LeftCTRL to switch mode”) for a game and wondering how should I store the mode.
Modulescripts are more performant, but the difference is negligible. Unless you’re accessing that value many times within a frame, it shouldn’t really matter. For your case values should be perfectly fine.
Yeah I’m not running anything every frame, mainly they just change the mode on user input so they could spam it of course but that’s nothing compared to running every frame
Literally 100% assuming here from the little experience I have, but here’s what I know:
Attributes use less memory than instance values, so if you need LOADS of values, use attributes.
I’m going to assume that there is no real difference in accessing instance values compared to attributes, maybe attributes are a little slower.
Modules will be the best of both worlds, using less memory than the both of them and likely being more performant
However, if you’re only storing 1 or 2 mode values, and changing them every few seconds, It really does not matter. Don’t overoptimize something that doesn’t need to be optimized, just do what you’re most comfortable with.
Okay Thanks, I understand. ModuleScripts are the most performant but as long as I’m not running something every single frame or anything expensive it should be fine