using UnityEngine;

public class Boostable : MonoBehaviour
{
	public float BoostAccel = 5f;
	public float DontBoostAboveSpeed = 1f;

	private bool boostTrigger = false;
	private Rigidbody2D rb;

	public void Boost()
	{
		boostTrigger = true;
	}

    void Start()
    {
		rb = GetComponent<Rigidbody2D>();    
    }

    void FixedUpdate()
    {
        if (boostTrigger)
		{
			if (rb.velocity.y > DontBoostAboveSpeed)
				return;

			Vector3 accel = Vector3.up * BoostAccel;
			Vector3 force = rb.mass * accel / Time.fixedDeltaTime;
			rb.AddForce(force);
			//Debug.Log(Time.fixedTime + ": Boosting; V " + rb.velocity.y);
			boostTrigger = false;
		}
	}
}
