title: i want that ball on collision should start moving reverse direction. Right now my ball just stop at detecting the collision
body: <pre><code>public class moveBall : MonoBehaviour {
  
  private const float SPEED = 5f;
  private Vector3 direction;
  private Vector3 inversedirection;
  private float distance =0f;
  private Vector3 lastPos;
  private RaycastHit hit = new RaycastHit();
  
  
  // Use this for initialization
  void Start () {
      direction = (new Vector3( 1.0f, 0.0f, 0.0f)).normalized;
      inversedirection = (new Vector3 (-1.0f, 0.0f, 0.0f)).normalized;
      lastPos = transform.position;
  
  }
  
  // Update is called once per frame
  void Update () {
      transform.position += direction * SPEED * Time.deltaTime;
  
      lastPos = transform.position;
      Debug.DrawRay (transform.position, direction * 2,  Color.green);
      if (Physics.Raycast (transform.position, direction, out hit, 2)) {
                      Debug.Log ("Hit");
                      print (lastPos.x);
                      if (hit.collider.gameObject.name == "Plane") {
                              Destroy (this);
                      }
              }
  
  
  }
  }
  </code></pre>
  
  <p>Please help. If someone can suggest me how to proceed. I want that that ball collides the plane and the moves opposite direction.I am using Raycast to detect the collision. </p>