using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Rigidbody))]
public class JitterDrag : MonoBehaviour {

	public Rigidbody rb;

	public float originalDrag;
	public float dragSpread = 3;

	public float delay;

	// Use this for initialization
	void Start () {
		rb = GetComponent<Rigidbody>();
		originalDrag = rb.drag;
	}
	
	// Update is called once per frame
	void FixedUpdate () 
	{
		delay -= Time.deltaTime;

		if (delay < 0) {
			rb.drag = originalDrag + Random.Range (-dragSpread, dragSpread);
			delay = Random.Range(0.5f,2.0f);
		}
	}
}
