Random Switch on enum

Hello guys,

i want to include a random character.
I have a enum for each parameter created , which is to be set for the character.
But how can I generate a random parameter of a enum now?

2 Likes

I have found a solution

but these appear very uncomfortable to me

is there a better one?

Enums are just integers, so you can just use random int to get random enums. If you want less clutter, you can use the Select node and hook it up to an enumerator.

You can see the select node in action on this image:


(the select node takes int, bool and enumerators as index values)

Sentura is correct. To expand on that answer, take a look at this screenshot. You need to get a random int, convert that int to a byte (because enums are bytes in UE4), then convert that byte to the enum type you’re using (firstnames, lastnames, genders etc), then set your variable.

6 Likes