• News

• Industries

• Learning & Support

• Community

• Marketplace

# Enumerations

Hi,
Is there a way within a blueprint to determine the total number of items within an enumeration?

Example

Enumeration FirstName (John,Terry,Chuck,Dave)

What I need to know is that there are a total of 4 items in the enumeration. Also, can you get a value of 3 to show the number of the last index type number on the enumeration?

Does nobody know if this can be done?

Yes you can, type the name of your enumeration when you do the search for nodes, it will give you all the options.
I don’t understand your second question.

Thanks for the info Nabiul!

The second question deals with the fact that the first element in an enumeration is 0. So if you get the number of entries in the enumeration, in a way it’s 1 too large for some functions. I am feeding this number into a random number picker and if it picks the max value (i.e. lets say 4 as in my above name example) it’s going to generate a “MAX EN” error message since the elements are 0-John,1-Terry,2-Chuck,3-Dave. It’s the same way that you have a LENGTH and LAST INDEX function with arrays.

You can just manually subtract 1 from the “number of entries” value when using it for those functions. It’s what you have to do when working with splines if you use the “get number of spline points” to determine the number of the last spline point, not that odd really.

Yea, that’s my current plan. It just seems like there should be a function for it if you know what I mean.

Thanks for the information on splines. While I’ve worked with them but I didn’t know that they have a similar issue. I will keep that in mind.

It’s funny, you can go to the Content Examples demo for splines and they have little comments on the Int math nodes: “since spline points start at index 0, we have to subtract 1 from the number of points to get the end point”.

I think it’s just how Epic expects it to be done when dealing with any list length that starts at index 0.

Index starting at Zero is a programming legacy which Epic use also in BP (Because BP is at the end progamming also). There are pros & cons to these, but it can be digest in time, like some BP/Programming syntax that feel weird for the non progarmmer. Just have to take note when you get things like length of array, or a particular value/reference of an index.