Will attributes cause performance issues in this?

I’m making a power bar for a game where the player can control their power for a mechanic. By pressing E, their power will constantly go up at a rate of 0.05 sec and vice versa, The thing is I store the power as an attribute inside the player, will that cause performance issues constanly setting the attribute so much or no?

1 Like

Using an attribute is one of the fastest ways to store data (I still prefer values though)
If you’re going to only need this value for this script/don’t require it for anything externally, though, I would recommend just using a variable in your code as opposed to an attribute/value since that is the fastest method

Attributes are very cheap. It’s similar to sending one value across a remote, but is actually quicker to replicate. You can test this by hooking an AttributeChanged or GetAttributeChangedSignal event to an object and seeing how many changes it can pick up from the server.

Since it is similar to a remote in the way it needs to send data across the network to replicate, this means that it is using the same amount of network bandwidth that you would use on a remote. For example, setting an attribute as a number would cost 4 bytes as a 32bit float, the equivalent of what it would cost to send one number across a remote. Similar to remote signals, as long as you’re not sending and updating thousands of attributes at an extremely fast rate, you’ll be completely fine.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.