using UnityEngine;
using System.Collections;

public class Movement : MonoBehaviour {

	public float currentSpeed;	//check the current Speed of Simon
	public float speed = 5000f;
	public Vector2 maxVecolity = new Vector2(5,5);

	private Rigidbody2D rigi;

	void OnBecameInvisible () {
		Destroy(this.gameObject);
	}

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

	// Update is called once per frame
	void Update () {
		currentSpeed = Mathf.Abs(rigi.velocity.x);
		var forceX = 0f;
		var forceY = 0f;
		if (currentSpeed < maxVecolity.x) {
			forceX = speed * -1;
			GetComponent<Rigidbody2D> ().AddForce (new Vector2 (forceX, forceY));
		} else {
			
		}

	}
}
