Generating Random number inside a For loop within Construction Script

I am trying to use a Random number inside a range. This number is being generated inside a for loop within Construction Script of my Actor. I want to have a random number everytime loop body is executed, but it seems that the random number is generated only on first pass of the loop and same number is used in next loop passes. Anybody faced this problem before?

Hello ambhar,

Unfortunately, I have been unable to reproduce the issue you are having. I was able to use a for loop to generate a random integer in the construction script, and I was getting a different value each time the loop body executed.

Are there any other details that you may have left out that could be helpful in reproducing? Also, if you are willing, you could create a test project that reproduces the issue you are having, and zip it up. If you upload that either here or on dropbox and provide me with a link, that would allow me to get a better understanding of exactly what is causing the error that you are experiencing.



Hey ,
I think I found the problem. I was trying to change the mesh in some instances of InstancedStaticMesh. But I believe it is not possible to add different Meshes to the different instances of a single InstancedStaticMesh.

That little info of yours helped me a lot. Thanks for sharing your solution/mistake.