public void Draw(SnakePoints s) { s.Fill(); s.SetColor(color); s.DrawCircle(position, Quaternion.LookRotation(Vector3.forward), radius * (lifetime / length)); s.NoFill(); s.SetColor(Color.black); s.DrawCircle(position, Quaternion.LookRotation(Vector3.forward), radius * (lifetime / length)); }
public void Update(SnakePoints s, float dt) { float t = Time.timeSinceLevelLoad * s.noiseSpeed; float n = (Mathf.PerlinNoise((position.x + t) * s.noiseScale, (position.y + t) * s.noiseScale) - 0.5f) * TWO_PI * 2f; velocity += new Vector3(Mathf.Cos(n), Mathf.Sin(n), 0f) * s.noiseIntensity * dt; velocity *= 0.9f; // decay lifetime -= dt; position += velocity; }