public void Update(WarmBasket s, float dt) { var head = points[0]; var t = Time.timeSinceLevelLoad * 0.25f; var nx = Mathf.PerlinNoise(t, head.x * 0.1f + offset) - 0.5f; var ny = Mathf.PerlinNoise(head.y * 0.1f + offset, t) - 0.5f; var nz = Mathf.PerlinNoise(t + offset + head.z * 0.1f, t + offset) - 0.5f; const float intensity = 1.0f; velocity.x += Mathf.Cos(nx * TWO_PI * 2f) * intensity; velocity.y += Mathf.Sin(ny * TWO_PI * 2f) * intensity; velocity.z += Mathf.Cos(nz * TWO_PI * 2f) * intensity; if (s.useGravity) { velocity += s.transform.InverseTransformDirection(Vector3.down) * 5f; } if (head.magnitude >= s.sphereRadius) { velocity += -head; } velocity *= decay; head += velocity * dt; head = head.normalized * Mathf.Clamp(head.magnitude, 0f, s.sphereRadius); points[0] = head; Chain(); }
public void Draw(WarmBasket s) { s.SetColor(color); for (int i = 1, n = points.Count; i < n; i++) { s.DrawLine(points[i - 1], points[i]); } s.Fill(); float t = (Mathf.Sin(offset + Time.timeSinceLevelLoad * (decay * 5.0f)) + 1.0f) * 0.5f + 0.5f; t = Mathf.Clamp01(t); t = t * t; s.DrawSphere(points[0], look, limit * 0.25f * t); }