Creating Instances or Tags

I am working on a combat system which uses a mixture of tags/attributes and temporary instances to determine player input/action. For instance, when a player gets stunned, I add a tag called “Stunned” onto their character, and whenever they try to move/attack I check to see if their character has the “Stunned” tag.

On the other hand, whenever a player clicks their mouse, I create a local instance in the player’s character called “mouseDown”, because it is imperative that I know if they are holding their mouse button down during a certain combo. However, I am unsure as to how else I can approach this – would it be more efficient to add a tag to the character called “mouseDown” instead of creating a local instance every time a player clicks?

I would be inclined to Attributes over Instances or Tags. Attributes should in theory be a lot quicker. Create the required attributes on player load and modify when necessary:

player:SetAttribute("mouseDown", false) -- Set the attribute
local isMouseDown = player:GetAttribute("mouseDown") -- Readthe attribute

From what I understand they are an extension to the OOP properties so can be set and retrieved faster than creating and modifying instances of any sort. It’s what I tend use in these scenarios.

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