# Array of Actors, set random Boolean on each but with limits.

**URL:** <https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088>\
**Category:** Blueprint\
**Tags:** random, unreal-engine, Array, Blueprint, question\
**Created:** [March 20, 2024, 10:10pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088 "2024-03-20T22:10:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Z3R0K0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Z3R0K0](https://forums.unrealengine.com/u/Z3R0K0)\
**Post date:** [March 20, 2024, 10:10pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/1 "2024-03-20T22:10:34Z")

</div>

Hello again Unreal Engine Forums.

I have an array of 10 actors. What I want to do is set 1 out of 3 possible Booleans on each actor at random. BUT I would like to know how to limit how many Booleans of a each type can be set. For Example:

10 Actors  
7 Booleans to Type 1 (Red)  
2 Booleans to Type 2 (Blue)  
1 Booleans to Type 3 (Green)

I would like all actors to be set with only 1 Boolean but I don’t want more than an assigned number of each Boolean to be set.

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [March 21, 2024, 12:27am UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/2 "2024-03-21T00:27:14Z")

</div>

Perhaps a function like this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/9/959e3803b06fde81813e25946a30aea41b0c21d7.png)

---

<div class="post-metadata">

**Author:** ![Z3R0K0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Z3R0K0](https://forums.unrealengine.com/u/Z3R0K0)\
**Post date:** [March 22, 2024, 2:22pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/3 "2024-03-22T14:22:35Z")

</div>

Thanks for your reply, I have managed to replicate this with the changes I needed but I can’t figure out how to use it properly.

When I execute the blueprint it is only setting one type for all. If I change the “Set Type” numbers on the node in the main blueprint, it only seems to effect which type is set, not the amount.

I’m not sure how to utilize this properly. Some further insight would be much appreciated.

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [March 22, 2024, 2:44pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/4 "2024-03-22T14:44:07Z")

</div>

Share the bp.

---

<div class="post-metadata">

**Author:** ![Z3R0K0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Z3R0K0](https://forums.unrealengine.com/u/Z3R0K0)\
**Post date:** [March 22, 2024, 3:14pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/5 "2024-03-22T15:14:34Z")

</div>

![Untitled](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/0/2e073dad8ad8538042fe7b0c4a231dd68ed90d6b.png)  
 ![Untitled2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/9/1098ec207aa93cfa1f506bb135f722bc48f8438b.jpeg)

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [March 22, 2024, 3:19pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/6 "2024-03-22T15:19:42Z")

</div>

Are Y, I and X local variables?.

---

<div class="post-metadata">

**Author:** ![Z3R0K0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Z3R0K0](https://forums.unrealengine.com/u/Z3R0K0)\
**Post date:** [March 22, 2024, 3:28pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/7 "2024-03-22T15:28:42Z")

</div>

![Untitled2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/c/b/7cb048d1847028d545bf2acaa16afe15e5860343.png)

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [March 22, 2024, 3:46pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/8 "2024-03-22T15:46:44Z")

</div>

Ok. Lets be sure the function is working as expected:

- Add a breakpoint to the return node. Should allow you to inspect the variables manually by hovering over them:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/d/9/5d972767c566e55980c9ccf694311dd4e3b6acb7.png)
- Then confirm that the input values are 7, 2, 1:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/8/1d8a7d2b780351e74839ceca9d49c2831e141632.png)
- Check to see if the bools were changed as expected:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/a/73a9e3d4c0c01524c366c98818d0a694f772523c.png)
- Finally make sure that X is {0.0, 0.0, 0.0}:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/f/0/8f02015dcc724a400e9fa08771730a728899819f.png)

If everything is working as expected here that means the bools are changed after elsewhere.

---

<div class="post-metadata">

**Author:** ![Z3R0K0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Z3R0K0](https://forums.unrealengine.com/u/Z3R0K0)\
**Post date:** [March 22, 2024, 4:00pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/9 "2024-03-22T16:00:56Z")

</div>

The inputs are confirming 7,2,1

All the bools are selecting the first option (Skeleton)

When checking the X array, is reporting 7,2,1

---

<div class="post-metadata">

**Author:** ![pezzott1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pezzott1/32/1215068_2.png) [@pezzott1](https://forums.unrealengine.com/u/pezzott1)\
**Post date:** [March 22, 2024, 4:05pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/10 "2024-03-22T16:05:00Z")

</div>

> [@Z3R0K0](#):
>
> When checking the X array, is reporting 7,2,1

Make sure that the Get node returns a reference, not a copy:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/e/5/8e5c565f4db4f1e180ae35034fad83a9587a9a03.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/9/d/09da2bac5272736a8e93c4342fe68592f98b016c.png)

Change it and try again.

---

<div class="post-metadata">

**Author:** ![Z3R0K0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Z3R0K0](https://forums.unrealengine.com/u/Z3R0K0)\
**Post date:** [March 22, 2024, 4:10pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/11 "2024-03-22T16:10:07Z")

</div>

That is where I went wrong then. The function is working perfectly now. Thank you for all your help.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [April 21, 2024, 4:10pm UTC](https://forums.unrealengine.com/t/array-of-actors-set-random-boolean-on-each-but-with-limits/1764088/12 "2024-04-21T16:10:25Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
