public CompleteHair(Material mat, GameObject anchor, Vector3 anchorOffset, float timeStep, float crossArea, int segNum, float segLength, float guideSegLength) { hairOb = new GameObject(); hairOb.AddComponent <LineRenderer>(); hairOb.GetComponent <Renderer>().material = mat; hairLine = hairOb.GetComponent <LineRenderer>(); hairLine.materials[0] = mat;//new Material(Shader.Find("Sprites/Default")); //hairLine.SetColors(Color.white, Color.white); guide = new SimpleHairCreator(anchor, anchorOffset, timeStep, crossArea, segNum, guideSegLength); hair = new HairCreator(anchor, anchorOffset, guide, hairLine, timeStep, crossArea, segNum, segLength); }
// Start is called before the first frame update public HairCreator(GameObject anchorOb, Vector3 offset, SimpleHairCreator guide, LineRenderer hairLine, float timeStep, float crossArea, int segNum, float segLength) { timestep = timeStep; area = crossArea; segAmount = segNum; anchor = anchorOb; anchorOffset = offset; guideCreator = guide; hair = hairLine; Vector3 currAnchorPos = anchor.transform.position + anchorOffset; //set up individual hair segments segment = new HairSegment[segAmount]; for (int i = 0; i < segAmount; i++) { // index, mass, initial position, initial velocity segment[i] = new HairSegment(i, 25, currAnchorPos - new Vector3(0, segLength * (i + 1), 0), new Vector3(0, 0, 0)); } }