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

public class FoodController : MonoBehaviour {

    #region private properties

    public float maxSpeed = 50;
    public GameObject currentGriper;

    Rigidbody2D _body;
    
    #endregion


    #region Setup

    // Use this for initialization
    void Start () {
        _body = GetComponent<Rigidbody2D>();
	}

    private void Update()
    {
        Vector2 vel = _body.velocity;
        Mathf.Clamp(vel.x, -maxSpeed, maxSpeed);
        Mathf.Clamp(vel.y, -maxSpeed, maxSpeed);
        _body.velocity = vel;
    }

    #endregion

    #region API

    public void UpdatePhysics(Vector2 target, float speed)
    {
        Vector2 current_pos = _body.position;
        _body.MovePosition(Vector2.Lerp(current_pos, target, Time.deltaTime * speed));
    }

    #endregion

}
