Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Oscillator {
- float min;
- float max;
- float value;
- float velocity;
- float speed;
- float target;
- public Oscillator(float min, float max, float speed) {
- this.min = min;
- this.max = max;
- this.speed = speed;
- target = (min+max) * 0.5f;
- value = min;
- }
- public float GetNext() {
- velocity += (value < target ? 1 : -1) * speed;
- value += velocity;
- return value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment