# How To "Gate" a Random Float?

**URL:** <https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480>\
**Category:** Blueprint\
**Tags:** timeline, random-numbers, unreal-engine, Blueprint, question\
**Created:** [August 21, 2015, 3:05pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480 "2015-08-21T15:05:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_36c38811](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36c38811](https://forums.unrealengine.com/u/anonymous_user_36c38811)\
**Post date:** [August 21, 2015, 3:05pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480/1 "2015-08-21T15:05:15Z")

</div>

Hello everybody! This is the first time I’m asking for help in this great community.

Here’s my problem:  
I’m trying to create an animated mesh inside of a blueprint. I’ve succeded in it except I dunno how to exactly obtain the kind of movement I was thinking about. I want this mesh to change Zscale smootly in a time set in a **Timeline** and a **SetTimer** I’m using to trigger the all thing. It all worked till I’ve added a **Random Float in Range** to obtain this randomized scale variations. Problem is I’d like to get the value frome the Random Float in Range only once at the beginning of the Timeline loop but i want the relative scale to change smoothly in the time I’ve set.

From what I’ve seen using a **Print text** the random float in range gives me a different value pretty much on every frame, so I was thinking if there is a way to “gate” that info so i can obtain it only once per cycle.  
As i said need the **Set Relative Scale** to work instead continuosly (like it is doing now getting fired from the “update” node of the timeline) to have that smooth scale variation i was talkin about.

Here is the screenshot of the actual blueprint:

 ![55167-question.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/e/0/ae0d657264a21e4c44decda515710e5e41e8d77b.jpeg)

I’m quite a noob and I know nothing of C++ and I’m trying to make things work via Blueprints.  
Any suggestion is welcomed by the way.

Please excuse my poor english and Thanks in advance to anybody who would/could help.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33e74471](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33e74471](https://forums.unrealengine.com/u/anonymous_user_33e74471)\
**Post date:** [August 21, 2015, 3:25pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480/2 "2015-08-21T15:25:32Z")

</div>

Get the random float at the beginning (between your RS event and your Timeline) and store it in a variable and then use that variable in your lerp.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_76e49ea2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_76e49ea2](https://forums.unrealengine.com/u/anonymous_user_76e49ea2)\
**Post date:** [August 21, 2015, 3:59pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480/3 "2015-08-21T15:59:48Z")

</div>

You need to store both, original scale value and new random scale value before timeline. Otherwise each action (in your example - Print Text and Set Relative Scale 3D) will ask for new value each frame. This will make lerp incorrect, both values will be changed every frame.

 ![55182-rs.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/8/af8ec3ddebfff3fe8fdc0b9e0fe5b248a2be1b9c.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36c38811](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36c38811](https://forums.unrealengine.com/u/anonymous_user_36c38811)\
**Post date:** [August 21, 2015, 4:38pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480/4 "2015-08-21T16:38:57Z")

</div>

A huge thank you guys!  
I’m sorry I can mark as correct just a single answer cause they are clearly both correct.  
I’ve choosen **Arida** one because it was the most complete (and with the blueprint!) but I cannot avoid to thank **mrooney** for givin the right answer so fast!  
I know it was a silly thing but you both helped a lot while a was stucked!  
I hope I could manage to help you back one of this days 😉  
You people are AWESOME!

p.s. @theadmins: I hope I’m not violating any rule of the answer hub by saying thanks in a answer form.  
If so, excuse me please, but I don’t know how to avoid saying how grateful I am to these people helping!  
Feel free to remove my answer if it is the case…but please don’t kick me out!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33e74471](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33e74471](https://forums.unrealengine.com/u/anonymous_user_33e74471)\
**Post date:** [August 21, 2015, 6:09pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480/5 "2015-08-21T18:09:14Z")

</div>

No problemo.

It looks like you added your thing as a comment not an answer (unless a mod changed it), but when you submit an answer you can select it to show up as a comment instead of an answer, and under every comment/answer there’s also an “add new comment” button where you can add comments that aren’t answers.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_36c38811](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_36c38811](https://forums.unrealengine.com/u/anonymous_user_36c38811)\
**Post date:** [August 23, 2015, 3:36pm UTC](https://forums.unrealengine.com/t/how-to-gate-a-random-float/329480/6 "2015-08-23T15:36:55Z")

</div>

No, it was no mod, it was me. I realized you could decide how to make the answer show up only after i wrote it (while actually submitting it). I wanted to make it a comment to the both of the answer you and Arida gave me, but I wanted to not “pollute” to much the thread with a copy paste instance so I went commenting my own question…I’m a total n00b XD
