public bool Update() { if (animationEnabled) { foreach (Attractor v in attractors) { v.Update(); } if (!cNoiseOsc.MoveNext()) { cNoisePrev = cNoiseNext; cNoiseNext = Random.Range(ceilMinStrength, ceilMaxStrength); } cNoise = Mathf.Lerp(cNoisePrev, cNoiseNext, cNoiseOsc.Current); if (!fNoiseOsc.MoveNext()) { fNoisePrev = fNoiseNext; fNoiseNext = Random.Range(floorMinStrength, floorMaxStrength); } fNoise = Mathf.Lerp(fNoisePrev, fNoiseNext, fNoiseOsc.Current); } return(animationEnabled); }
public Vector3 GetNextPosition() { if (curvatureEnabled) { if (!hCurveOsc.MoveNext()) { hCurvePrev = hCurveNext; hCurveNext = Random.Range(-maxHorizontalCurve, maxHorizontalCurve); } hCurve = Mathf.Lerp(hCurvePrev, hCurveNext, hCurveOsc.Current); if (!vCurveOsc.MoveNext()) { vCurvePrev = vCurveNext; vCurveNext = Random.Range(-maxVerticalCurve, maxVerticalCurve); } vCurve = Mathf.Lerp(vCurvePrev, vCurveNext, vCurveOsc.Current); Vector3 pXZ = new Vector3(position.x, 0f, position.z); Vector3 next = pXZ + Quaternion.Euler(0f, hCurve, 0f) * direction * step.z; direction = (next - pXZ).normalized; position = new Vector3(next.x, position.y + vCurve, next.z); } else { position += step; } //Debug.DrawRay(position, direction, Color.white, 100f); return(position); }
public void Update() { if (!osc.MoveNext()) { posPrev = posNext; posNext.x = Random.Range(bounds.xMin, bounds.xMax); posNext.y = Random.Range(bounds.yMin, bounds.yMax); } pos = Vector3.Lerp(posPrev, posNext, osc.Current); //Draw(); }
private void AnimateSharedMaterial() { if (material == null) { if (chunkCount > 0) { lumOsc = new Oscillator(300f, 400f); material = transform.GetChild(0).GetComponent <Renderer>().sharedMaterial; } } else { if (!lumOsc.MoveNext()) { lumPrev = lumNext; lumNext = Random.Range(-0.4f, 0.4f); } lum = Mathf.Lerp(lumPrev, lumNext, lumOsc.Current); material.color = Color.HSVToRGB(0.085f, 0.3f, 0.4f + lum); material.SetFloat("_Glossiness", 0.4f - lum); material.SetFloat("_Metallic", 0.5f - lum * 0.5f); } }