Fling a ball?

How would fling a ball or object with the mouse. So lets say i have a set of goals, and i want the player to click and drag (in a fling motion) and when they click the ball is spawned, and then where they their mouse moving towards initially is where the ball start heading…

heres an example:

24547-1.png
the box is the goal.
circle is the ball.
the red line represents the ball direction and where its heading
the green line is the mouse direction and where its heading. the start of the green line is where the player clicked and where the ball was spawned.

This uses mouse or finger to generate an force called pPush, which is then applied to a ball.

nFrame is Time.deltaTime
all other vars with a “p” in front need declared at the top of your script.

void FingerThing(float nFrame){
    		pGo=false;
    		if(Input.GetKey(KeyCode.Mouse0)){
    			Vector2 vFinger = Input.mousePosition;
    			Vector3 vPlace = this.camera.ScreenToWorldPoint (new Vector3 (vFinger.x,vFinger.y,100));
    			
    			
    			if(!pOldPress){
    				pTime=nFrame;
    				pStartPos=vPlace;
    			}else{
    				pTime+=nFrame;
    			}
    			pFirePos=vPlace;
    			pOldPress=true;
    		}else{
    			if(pOldPress){
    				pPush=(pFirePos-pStartPos)/pTime;
    				pGo=true;
    			}
    			pOldPress=false;
    		}
    	}