Can I create an Enum which it's values are a Struct I've made?

Hello!

For the system I’m trying to make, what works the best is to have an enum who’s values are a custom struct. Then in this enum, I can populate the values of each “struct value” individually.

I’m not sure if that explains it well, but here’s the bottom line: I want my item system to contain a struct that dictates the value of each item.
Example

Base Item Struct
Name:
Value:

And from that, I create an “enum” that contains my items:

Enum BP
[
Red Coin Item
Name: RedCoin
Value: 5

Blue Coin Item
Name: BlueCoin
Value: 10
]

Now I understand that enums work with just a name for each value (maybe), so if there’s a way to accomplish this sytem with another type (or better) of data structure I’d appreciate some insight.

Thank you in advance.

Hi @VirtualFriend509

Thats not how enums work, all they do is replace unique values with recogniseable words for ease.

All you need is to make an array of your struct.

This allows you to have a list of individual items , each holding all the information from your structs

As I thought.

I want to have these items made before the game executes, is there a different way to do this without arrays? Something very similar to an enum.

Thanks again.

I should add that I want to achieve this using blueprints only if possible.

Hey @VirtualFriend509!

So what you want here isn’t an Enum OR a struct… You should use a Data Asset!

There isn’t a lot of documentation or official tutorials here on the Epic Dev Community for Blueprint, but youtube will have a good amount to cover it! I once saw a video where someone used Data Assets to make a pokedex using their fake Pokemon. Stats, height, weight etc. included in said asset along with identifying # and name.

They used to require C++ but do not any longer.
If that’s not what you’re looking for, you can also go with Data Tables!

Disclaimer: This link is not affiliated with Epic Games, Unreal Engine, or their partners.

1 Like

Thank you @Mind-Brain !!

I was initially using Data Assets, but I was storing all the items inside one data asset instead of making multiple of them, ala prefab. This was what I needed, cheers!

1 Like