void BuildObjectLinks(MegaShape path) { float len = path.splines[curve].length; if (LinkSize < 0.1f) { LinkSize = 0.1f; } // Assume z axis for now float linklen = (linkOff1.y - linkOff.y) * linkScale.x * LinkSize; int lc = (int)(len / linklen); if (lc != linkcount) { InitLinkObjects(path); } Quaternion linkrot1 = Quaternion.identity; linkrot1 = Quaternion.Euler(rotate); float spos = start * 0.01f; Vector3 poff = linkPivot * linkScale.x * LinkSize; float lastalpha = spos; Vector3 pos = Vector3.zero; Matrix4x4 pmat = Matrix4x4.TRS(poff, linkrot1, Vector3.one); Vector3 lrot = Vector3.zero; Quaternion frot = Quaternion.identity; #if UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2017 Random.InitState(seed); #else Random.seed = seed; #endif for (int i = 0; i < linkcount; i++) { float alpha = ((float)(i + 1) / (float)linkcount) + spos; Quaternion lq = GetLinkQuat(alpha, lastalpha, out pos, path); lastalpha = alpha; Quaternion lr = Quaternion.Euler(lrot); frot = lq * linkrot1 * lr; if (linkobjs[i]) { Matrix4x4 lmat = Matrix4x4.TRS(pos, lq, Vector3.one) * pmat; linkobjs[i].localPosition = lmat.GetColumn(3); linkobjs[i].localRotation = frot; linkobjs[i].localScale = linkScale * LinkSize; } if (randRot) { float r = Random.Range(0.0f, 1.0f); lrot = (int)(r * (int)(360.0f / MegaUtils.LargestValue1(linkRot))) * linkRot; } else { lrot += linkRot; } } }