Hey guys, I am trying to add some more randomization in to this procedurally generated fractal script and it is pitching some fits that i cannot seem to fix.
here is the script
using UnityEngine;
using System.Collections;
public class Fractal : MonoBehaviour
{
public Mesh mesh;
public Material material;
private int depth;
public int maxDepth;
public float childScale;
private Material[] materials;
private float _nr = Random.Range(-80f, -100f);
private float _r = Random.Range(80f, 100f);
private Color RandomColour()
{
float r = Random.value;
float g = Random.value;
float b = Random.value;
return new Color(r, g, b);
}
private void InitializeMaterials ()
{
materials = new Material[maxDepth + 1];
for (int i = 0; i <= maxDepth; i++)
{
materials *= new Material(material);*
-
material.color = RandomColour();*
-
}*
-
}*
-
private void Start ()*
-
{*
-
if (materials == null)*
-
{*
-
InitializeMaterials();*
-
}*
-
gameObject.AddComponent<MeshFilter>().mesh = mesh;*
-
gameObject.AddComponent<MeshRenderer>().material = materials[depth];*
-
gameObject.AddComponent<Material>*
-
if (depth < maxDepth)*
-
{*
-
StartCoroutine(CreateChildren());*
-
}*
-
}*
-
private static Vector3 childDirections =*
-
{*
-
Vector3.up,*
-
Vector3.right,*
-
Vector3.left,*
-
Vector3.forward,*
-
Vector3.back;*
-
}*
-
private static Quaternion childOrientations =*
-
{*
-
Quaternion.identity,*
-
Quaternion.Euler(0f, 0f, _nr),*
-
Quaternion.Euler(0f, 0f, _r),*
-
Quaternion.Euler(_r, 0f, 0f),*
-
Quaternion.Euler(_nr, 0f, 0f);*
-
}*
-
private IEnumerator CreateChildren ()*
-
{*
-
for (int i = 0; i < childDirections.Length; i++)*
-
{*
-
yield return new WaitForSeconds(Random.Range(0.1f, 0.5f));*
-
new GameObject("Fractal Child").AddComponent<Fractal>().Initialize(this, i);*
-
}*
-
}*
-
private void Initialize (Fractal 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];*
- }*
}
and the errors that i am getting are
Assets/Fractal Stuff/Fractal.cs(51,18): error CS1525: Unexpected symbolif'* *Assets/Fractal Stuff/Fractal.cs(62,29): error CS1525: Unexpected symbol
;‘, expecting,', or
}’
Assets/Fractal Stuff/Fractal.cs(65,15): error CS8025: Parsing error
i have a feeling it is something stupid i missed but i cannot seem to find it so any help would be appreciated