title: Throwing an object at an arch in 2D using C#
body: <p>I am trying to create a 2D game where the user throws a bomb at an arch from point A(which is a fixed point) to point B(which will change constantly). My trouble comes in when I am trying to make the bomb move towards the target location, I cannot seem to get it to go where I touch. I also cannot get it to go there in an arch. Is there anyone that can assist me in solving this problem. Other help that I have researched is for a 3D situation and I have trouble converting it into a 2D model.</p>
  
  <p>Below are the two scripts that are being used together.</p>
  
  <pre><code>public class PlayerController : MonoBehaviour {
  
  public int[] distanceToThrow;
  public int[] bombToThrow;
  public GameObject bomb;
  public Transform throwOrigin;
  public Vector2 throwSpeed;
  public float gravity;
  //public Transform throwPointPos;
  public Vector2 throwDestination;
  public float flightSpeed;
  public float throwTimer;
  public float throwResetTimer;
  public float landingTime;
  public Vector2 touchPos;
  
  private BombController theBomb;
  private Rigidbody2D bombRB;
  
  //private Camera theCamera;
  
  // Use this for initialization
  void Start () {
      //theCamera = FindObjectOfType&lt;Camera&gt;();
      theBomb = FindObjectOfType&lt;BombController&gt;();
      bombRB = theBomb.GetComponent&lt;Rigidbody2D&gt;();
  }
  
  // Update is called once per frame
  void Update()
  {
      if (throwTimer &gt; 0)
      {
          throwTimer -= Time.deltaTime;
          // Using a single touch as control - Letholor
      }
      else if (Input.touchCount &gt; 0)
      {
          Touch touch = Input.GetTouch(0);
          touchPos = new Vector2(touch.position.x, touch.position.y);
          Debug.Log("You are touching at position: " + touchPos);
         /* Ray ray = Camera.main.ScreenPointToRay(touchPos);
          RaycastHit hitResult;
          Physics.Raycast(ray, out hitResult);*/
          Vector2 throwDestination = touchPos;
          Debug.Log("Throw destination is " + throwDestination);
          SendBomb(throwDestination);
      }
  
  }
  
  public void SendBomb(Vector2 throwDestination) {
  
      if (throwTimer &gt; 0)
      {
          Debug.Log("Cooling down.");
          return;
      }
  
      throwTimer = throwResetTimer;
      Debug.Log("Throwing bomb to " + throwDestination);
      //Instantiate(bomb, throwOrigin.position, throwOrigin.rotation);
      GameObject newBomb = Instantiate(bomb, throwOrigin.position, throwOrigin.rotation);
      newBomb.GetComponent&lt;BombController&gt;().SetThrowDestination(touchPos - throwDestination);
     }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>public class BombController : MonoBehaviour {
  
  public int bombTimer;
  public float explosionRadius;
  public int resetTimer;
  public bool exploded;
  public Animation anim;
  private Rigidbody2D bombRigidbody;
  public float bombSpeed;
  public float gravity;
  private PlayerController thePlayer;
  
  // Use this for initialization
  void Start () {
      bombRigidbody = GetComponent&lt;Rigidbody2D&gt;();
      thePlayer = FindObjectOfType&lt;PlayerController&gt;();
  }
  
  // Update is called once per frame
  void Update () {
  }
  
  private void OnCollisionEnter2D(Collision2D collision)
  {
      if (collision.gameObject.tag == "Ground" || collision.gameObject.tag == "Bomb")
      {
          bombRigidbody.velocity = new Vector2(0, 0);
      }
  }
  
  public void Detonate()
  {
      anim.Play("explode");
      exploded = true;
  }
  
  public void SetThrowDestination(Vector2 throwDestination)
  {
      bombRigidbody.velocity = throwDestination * bombSpeed;
  }
  </code></pre>
  
  <p>}</p>