# How to force a new random number every time?

**URL:** <https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 14, 2015, 5:58am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905 "2015-03-14T05:58:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![brentJmcewan\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brentJmcewan\_1](https://forums.unrealengine.com/u/brentJmcewan_1)\
**Post date:** [March 14, 2015, 5:58am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905/1 "2015-03-14T05:58:50Z")

</div>

> **[Google Drive: Sign-in](https://accounts.google.com/v3/signin/identifier?dsh=S1493999703%3A1683227799938038&continue=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0BymIiQUJGNmfbUNMWjRpQUZRYUU%2Fview%3Fusp%3Dsharing&followup=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0BymIiQUJGNmfbUNMWjRpQUZRYUU%2Fview%3Fusp%3Dsharing&ifkv=Af_xneExyDDwyV5zq9EZOfVEeThw0ibN3erA8Ci-JnVEpWUHvv34oA7hGGPYO2AInhMj-1CTNkoKDQ&osid=1&passive=1209600&service=wise&flowName=GlifWebSignIn&flowEntry=ServiceLogin)**
>
> Access Google Drive with a Google account (for personal use) or Google Workspace account (for business use).

I am seeding a new random number with the time. However, when all of my seperate ai characters put in the call to make use of this function they are all getting the same random number.

How can I make it so it forces a new random number each time the function is called?

---

<div class="post-metadata">

**Author:** ![brentJmcewan\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brentJmcewan\_1](https://forums.unrealengine.com/u/brentJmcewan_1)\
**Post date:** [March 14, 2015, 6:00am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905/2 "2015-03-14T06:00:27Z")

</div>

> **[Google Drive: Sign-in](https://accounts.google.com/v3/signin/identifier?dsh=S1493999703%3A1683227799938038&continue=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0BymIiQUJGNmfbUNMWjRpQUZRYUU%2Fview%3Fusp%3Dsharing&followup=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F0BymIiQUJGNmfbUNMWjRpQUZRYUU%2Fview%3Fusp%3Dsharing&ifkv=Af_xneExyDDwyV5zq9EZOfVEeThw0ibN3erA8Ci-JnVEpWUHvv34oA7hGGPYO2AInhMj-1CTNkoKDQ&osid=1&passive=1209600&service=wise&flowName=GlifWebSignIn&flowEntry=ServiceLogin)**
>
> Access Google Drive with a Google account (for personal use) or Google Workspace account (for business use).

I couldnt make the image appear so there is a link here to it

---

<div class="post-metadata">

**Author:** ![Allar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Allar](https://forums.unrealengine.com/u/Allar)\
**Post date:** [March 14, 2015, 6:18am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905/3 "2015-03-14T06:18:54Z")

</div>

You can create a random stream and store it in your GameMode blueprint, then when your AI needs a random number, have them use the GameMode’s random stream. This way they are all pulling from the same random stream instead of all generating their own identical random numbers. If you don’t want to use GameMode, you can store random streams in the AIs themselves as long as you are sure to seed the random streams with unique streams.

---

<div class="post-metadata">

**Author:** ![brentJmcewan\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brentJmcewan\_1](https://forums.unrealengine.com/u/brentJmcewan_1)\
**Post date:** [March 14, 2015, 6:42am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905/4 "2015-03-14T06:42:11Z")

</div>

I just now created a new stream in the my character construction script, stored the stream in my character and then changed the get random function to access that one stream. For some reason each individual ai when it calls the function still gets the same random number each… I figure this is the same as creating one in game mode as its still the one stream, but that didnt work either… any suggestions?

---

<div class="post-metadata">

**Author:** ![brentJmcewan\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brentJmcewan\_1](https://forums.unrealengine.com/u/brentJmcewan_1)\
**Post date:** [March 14, 2015, 6:45am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905/5 "2015-03-14T06:45:03Z")

</div>

To clarify, my character is my player, and the ai are calling the player to give them a random number - but they are all getting the same random number… i have tried many things but this seems to always be the case

---

<div class="post-metadata">

**Author:** ![brentJmcewan\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@brentJmcewan\_1](https://forums.unrealengine.com/u/brentJmcewan_1)\
**Post date:** [March 14, 2015, 6:58am UTC](https://forums.unrealengine.com/t/how-to-force-a-new-random-number-every-time/310905/6 "2015-03-14T06:58:38Z")

</div>

Never mind - i think the problem is with a while loop earlier on just being skipped so its not setting the random number on the blackboard… Now to find out why the while loop is skipping… thanks for your help
