Hi everyone,
I’m developing a tower defense game (inspired by Plants vs. Zombies) and I’ve run into an architectural issue with my modifier system.
I want my unit selection UI (where the player chooses which units to use for the level) to display each unit’s stats with any active modifiers already appliedm for example, a “cost reduction” modifier should make the displayed cost lower in the selection menu.
Right now, my UI is populated from an array of Class References for each unit type.
This means the UI can only access the Class Defaults, so modifiers (which are applied at runtime) aren’t reflected there.
My modifier logic currently runs on object instances (after a unit is spawned and placed in the world).
I can’t figure out how to make this work cleanly using only class references, without a major refactor.
Originally, this wasn’t an issue since I didn’t have modifier, just direct upgrades implemented as separate classes.
Recently I thought about switching from class references to object references for the selection system, basically creating preconfigured objects of each unit before gameplay starts.
This would let me:
Apply modifiers and upgrades directly on those prototype instances
Show their real, updated stats in the UI
Then spawn gameplay units later by copying data from these preconfigured units
But I’m not sure if this is the best or most efficient approach in UE5 Blueprints (or if it should be done differently in C++).
My questions are:
Is switching to object references (prototype instances) a good solution for this problem?
If so, what’s the recommended way to set up and store those prototypes (in a Level Manager, DataAsset, or something else)?
Or is there a better architecture altogether for handling modifiers and upgrades in a selection UI?
Any advice or examples would be greatly appreciated.
Thanks in advance.