# Random Switch on enum

**URL:** <https://forums.unrealengine.com/t/random-switch-on-enum/348532>\
**Category:** Character & Animation\
**Tags:** random, ENUM, unreal-engine, Blueprint, question\
**Created:** [February 24, 2016, 4:08pm UTC](https://forums.unrealengine.com/t/random-switch-on-enum/348532 "2016-02-24T16:08:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathrim](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mathrim](https://forums.unrealengine.com/u/Mathrim)\
**Post date:** [February 24, 2016, 4:08pm UTC](https://forums.unrealengine.com/t/random-switch-on-enum/348532/1 "2016-02-24T16:08:35Z")

</div>

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?

 ![79754-bildschirmfoto+2016-02-24+um+17.02.50.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/2/f/92fd3dff7bf75ac903fd960f665414340d7f578d.png)

---

<div class="post-metadata">

**Author:** ![Mathrim](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Mathrim](https://forums.unrealengine.com/u/Mathrim)\
**Post date:** [February 24, 2016, 4:25pm UTC](https://forums.unrealengine.com/t/random-switch-on-enum/348532/2 "2016-02-24T16:25:50Z")

</div>

I have found a solution

but these appear very uncomfortable to me

is there a better one?

---

<div class="post-metadata">

**Author:** ![Sentura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sentura](https://forums.unrealengine.com/u/Sentura)\
**Post date:** [February 25, 2016, 12:59am UTC](https://forums.unrealengine.com/t/random-switch-on-enum/348532/3 "2016-02-25T00:59:22Z")

</div>

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:

 ![46177-solus.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/a/f/9af4ebe90851735618caa85330cdf0d0da0f327e.png)  
(the select node takes int, bool and enumerators as index values)

---

<div class="post-metadata">

**Author:** ![Baeldan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Baeldan](https://forums.unrealengine.com/u/Baeldan)\
**Post date:** [February 25, 2016, 1:13am UTC](https://forums.unrealengine.com/t/random-switch-on-enum/348532/4 "2016-02-25T01:13:05Z")

</div>

![79808-randomenum.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/8/f/58fb970dbb708096a129af535e5ee92899eb190b.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![OrkzToporem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OrkzToporem](https://forums.unrealengine.com/u/OrkzToporem)\
**Post date:** [April 28, 2025, 1:00pm UTC](https://forums.unrealengine.com/t/random-switch-on-enum/348532/5 "2025-04-28T13:00:44Z")

</div>

better solution (not hardcoding number of options in enum):

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/6/4/f64a958015869b7ca0038cf5135886f22a15f629.png)
