using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FluidDrag : MonoBehaviour {

	[Range (1f, 2f)]
	public float velocityExponent; // [dimensionless]

	public float dragConstant; //

	private PhysicsEngine pe;

	// Use this for initialization
	void Start () {
		pe = GetComponent<PhysicsEngine>();
		
	}
	
	// Update is called once per frame
	void FixedUpdate () {
		Vector3 directionVector = pe.velocity;
		float speed = directionVector.magnitude;

		pe.AddForce(CalculateDrag(speed) * -directionVector.normalized);
	}

	float CalculateDrag(float speed) {
		return Mathf.Pow(speed, velocityExponent) * dragConstant;

	}
}
