This is my best attempt at trying to do this, by populating the Unity random seed value with an amalgamation of semi-unique values pulled from parts of the scene and splice them together with the normally "DateTime.Now.Ticks" default seed value Unity supposedly uses.
The reason for this being (atleast from what I can tell), that since this random seed is based on the ticks I believe the system has currently tracked. That would have me believe that since these generation calculations are happening within a few system ticks most likely, this seed value is not changing much during this time, causing noticeable patterns in the end.
But I'd like to know if I'm just being dense here thinking this attempt of mine will be any better potentially, here is what it looks like in code so far:
Code: Select all
string unitySeed = DateTime.Now.Ticks.ToString();
int xPos = (int)oldLootPileTransform.localPosition.x;
int yPos = (int)oldLootPileTransform.localPosition.y;
int zPos = (int)oldLootPileTransform.localPosition.z;
string coordText = xPos.ToString() + yPos.ToString() + zPos.ToString();
string loadIDText = llcObj.LoadID.ToString();
string combinedText = unitySeed.Substring(0, 3) + coordText + loadIDText + unitySeed.Substring(4);
string truncText = (combinedText.Length > 10) ? combinedText.Substring(10) : combinedText; // Might get index out of range, but will see.
int seed = int.Parse(truncText);
UnityEngine.Random.InitState(seed); // This is to attempt to combat patterns in generation due to this all happening in a small period of time with a similar system-time seed by default.
The idea is to populated this seed value for when the chest and lock materials are being "rolled", then when that is said and done for each individual chest, reset the seed value to the Unity default at the end, as to try and not influence other systems by using the seed I created in this case.
Any advice/critique on this method and random generation patterns in general would be appreciated, thanks.