private void Initialize(FractalScript parent, int childIndex) { mesh = parent.mesh; material = parent.material; maxDepth = parent.maxDepth; depth = parent.depth + 1; childScale = parent.childScale; transform.parent = parent.transform; transform.localScale = Vector3.one * childScale; transform.localPosition = childDirections[childIndex] * (0.5f + 0.5f * childScale); transform.localRotation = childOrientations[childIndex]; }
// Establishes variables for new children objects which were set for original object // Just put all the variables up there in here. Just set variable = parent.variable if u wanna keep it the same void InitializeObjects(FractalScript parent, int childIndex) { meshs = parent.meshs; materials = parent.materials; maxDepth = parent.maxDepth; // Increases the depth of the object ensuring the recursive (shout out to big J) loop caused by the creation of multiple instances of this script is stopped eventually depth = parent.depth + 1; // sets childScale for new object randomChildScale = parent.randomChildScale; originalChildScale = parent.originalChildScale; if (randomChildScale) { childScale = parent.originalChildScale * Random.Range(minChildMultiplier, maxChildMultiplier); } else { childScale = parent.childScale; } spawnProbablility = parent.spawnProbablility; maxRotationSpeed = parent.maxRotationSpeed; maxTwist = parent.maxTwist; // this nests the new object in the parent transform.parent = parent.transform; // sets the scale of the object equal to (1,1,1) * childscale transform.localScale = Vector3.one * childScale; // Moves the new block up 0.5 + half the block size relative to the parent object transform.localPosition = childDirections[childIndex] * (0.5f + 0.5f * childScale); // Adjusts rotation so that blocks are not created inside of each other. transform.localRotation = childOrientations[childIndex]; }