Duplicate Actors Share BeginPlay Logic Using Async

For the record: No, you passed an integer value to that function, which means that the Sleep will be called with the same number each time under a single while loop. So the code flow is like this:

  • create a random stream
  • get a random number between 1-5 (let’s say 2)
  • call PrintSomething with this value (2)
  • in the while loop sleep for this time (2)

What @UnrealEverything meant by passing the FRandomStream to the PrintSomething function is that instead of an int parameter, you have the FRandomStream* as a parameter, and call RandRange inside your while loop.

Setting it to nullptr is not enough, this is not a managed (garbage collected) ecosystem. A modern approach is to use a managed pointer to automatically delete the object once it’s going out of scope.

1 Like