using UnityEngine;
using System.Collections;

public class BallBehavior : MonoBehaviour 
{
	public float desiredSpeed = 18.0f;
	public float lostBallDepth = -40.0f;

	void Awake () 
	{
		rigidbody.velocity = new Vector3(0, 0, desiredSpeed);
	}

	void FixedUpdate () 
	{
		rigidbody.velocity = rigidbody.velocity/rigidbody.velocity.magnitude * desiredSpeed;

        //Is the ball below the paddle? Then it's game over.
        if(transform.position.z <= lostBallDepth)
		{            
			GameManager.gameManagerRef.LostBall();
            Destroy(gameObject);
        }
	}
}
