# Help with replicating Random Streams

**URL:** <https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine, question\
**Created:** [January 5, 2025, 8:04pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404 "2025-01-05T20:04:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 5, 2025, 8:04pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/1 "2025-01-05T20:04:21Z")

</div>

Hello,  
im building an online randomly generated map using Procedural Mesh Component, i tried to replicate PM Component but no luck,  
so i decieded to use Random Stream and let the cleint spawn the map synced with server,  
Unfortunately i wasnt able to achieve that, it seems like the servers and the cleints random stream is out of sync even when having the same seed.

 ![Screenshot (71)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/e/c/cec8cc4d5e8f8d2ae1c58e31e9663316fd772696.png)  
this happens in Begin Play of the actor responsable for genrating the map, this actor is set to replicate.

 ![Screenshot (72)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/8/0f8b6ca95f243c6ab915d84129e4978eb0d83ba1.png)  
i even tried to sequence some of the random settings, i thought maybe unreal change the assign order each time.

my question is, how to sync both server and cleints random stream, and have the same map layout by having the same random numbers? the map generation take up to 500 random numbers to make the final map.

---

<div class="post-metadata">

**Author:** ![Rev0verDrive](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rev0verdrive/32/907214_2.png) [@Rev0verDrive](https://forums.unrealengine.com/u/Rev0verDrive)\
**Post date:** [January 5, 2025, 8:36pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/2 "2025-01-05T20:36:52Z")

</div>

First off you’re setting the same variable 3 times.  
Secondly, have the server set the variables and replicate them to you.

---

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 6, 2025, 4:46pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/3 "2025-01-06T16:46:40Z")

</div>

hi,  
thanks for replying.

about the variable set 3 times, its just a desperate move by me to fix the issue, i thought maybe unreal change thier order of excuting the random pure function each time, so i sequenced it to try forcing unreal a fixed order of retreiving the random numbers, for the sake of Random Streams sequence of random nymbers.  
below was my normal setting.

 ![Screenshot (73)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/f/a1f330ab508a860448243f1412f6021c5141495e.png)

about your suggestion to make the variables on server and replicate,  
unfortunately thats not possible since my map generating logic nest the same function inside of it to make multiple generated paths, and most of the variables used are local vars inside of that function.

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 6, 2025, 4:54pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/4 "2025-01-06T16:54:03Z")

</div>

Hey,

So yeah you will need this seed value to be the same here and then also the sequence of events to be the same otherwise the order at which it pulls the numbers from the stream will be different.

---

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 6, 2025, 5:12pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/5 "2025-01-06T17:12:45Z")

</div>

just to add another try.  
i tried to replicate the Random Stream itself but no luck, like below

below just to show that i replaced all normal random with stream randoms

---

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 6, 2025, 5:17pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/6 "2025-01-06T17:17:13Z")

</div>

hi,

yeah sequence of function code is not changing, i dont even call any other actor except a Function Library.

Could it be this happening because of im trying on the same device?

 ![Screenshot (74)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/2/b628cf222e8339b196435fc7ff0b3d9504abfc52.png)

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 6, 2025, 5:23pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/7 "2025-01-06T17:23:23Z")

</div>

I wouldn’t expect that to be the case, can you try printing the seed of the stream at the start and then just running a series of Print Strings grabbing a random value from the stream and checking if they are the same outside of the map logic.

---

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 6, 2025, 5:46pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/8 "2025-01-06T17:46:14Z")

</div>

thanks @JakeSimpson for your debugging idea, i shouldve tried that the first thing.  
below shows consistency in random outcome, and we can say the random stream is replicated perfectly here.  
so the issue must be with the map logic, even though i ran out of workarounds to solve it, i might have to change the whole approach.

---

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 6, 2025, 7:07pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/9 "2025-01-06T19:07:47Z")

</div>

hi all,

i believe i found the issue, even though i havent found the sulotion yet.

i have a section in the map function that spawn actors, and not all actors are allowed to be spawned in a client, e.g. enemies, they are spawned only on server and replicate.

when i excluded this section, the map logic synced generation perfectly with client.  
but with using that section the server and client seed get out of sync.

**new question, does Has Authority node affect Random Stream?**

* * *

below showing working synced generation after excluding actor spawning section

* * *

below showing the issue section

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 7, 2025, 9:44am UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/10 "2025-01-07T09:44:16Z")

</div>

So its not that the Has Authority specifically is affecting the Stream but what is happening is due to the Pure nodes you have there.

With this section here on the Client you use the Bool to check whether to spawn which runs the Random Int in Stream. That bool is false so it continues.

Whereas on the server this returns true and therefore re runs the Random Int From Stream for each other pin you pull out from that node.

To solve this, cache the returned struct from the Get and use that instead of breaking it as you have there.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/2/212768d979aaf6bde8e54950c2b8c0d730d3b79b.jpeg)

---

<div class="post-metadata">

**Author:** ![S3OD1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@S3OD1](https://forums.unrealengine.com/u/S3OD1)\
**Post date:** [January 7, 2025, 3:41pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/11 "2025-01-07T15:41:04Z")

</div>

thanks man for spotting the issue,  
yes indeed, when there is a slight change of code between server and client the Random Seed gets unsynced.

this is the way i approached and thankfully its working.

replaced spawning, in the generator function, with a spawn array

 ![Screenshot (76)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/d/6/2d663ed199cb8dca5f0c49c98a4a4afdce88a3f5.png)

==========

spawn after the generator function finishes

 ![Screenshot (78)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/b/3bbfb4f4a5137cc247595fa26e1ed8f706904b5f.png)  
 ![Screenshot (77)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/4/7/047a7e6246cedc11e68db5a59bec4806118bb040.png)

=========

thanks a lot Jake for your help, and please tell me if you have any note on my approach.

---

<div class="post-metadata">

**Author:** ![JakeSimpson](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jakesimpson/32/1008711_2.png) [@JakeSimpson](https://forums.unrealengine.com/u/JakeSimpson)\
**Post date:** [January 7, 2025, 4:13pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/12 "2025-01-07T16:13:55Z")

</div>

Yeah that looks great, happy to help @S3OD1 😄

---

<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:** [February 6, 2025, 4:14pm UTC](https://forums.unrealengine.com/t/help-with-replicating-random-streams/2261404/13 "2025-02-06T16:14:44Z")

</div>

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