How do I get my character to shoot a projectile in the direction of the cursor?

(EDIT): Ok, I’m creating a 2-d game. I would like my character to be able to shoot projectiles from a spawnpoint in front of him in the direction of the cursor upon clicking
on the screen.

19994-diagram.png

I can already spawn the projectile at the spawn point and apply forces to it and make it move. However I do not know how to find the angle for it to shoot at the cursor.

Answers Appreciated.

you can calculate the direction from which to shoot through simple calculations:

function OnMouseDown(){
   var ShootDir : Vector2 = Vector2(Input.mousePosition.x - character.transform.position.x,Input.mousePosition.y - character.transform.position.y) 
}

then instantiate your projectile, and either add force to move it with physics, or just move it in that direction

as for charging up:

if you want your shot to charge, while the user is pressing the button:

function Update(){
   var timer : float = 0;
   var isCharing : boolean = false;
   if(isCharging){
      timer += Time.deltaTime;
   }
}

function OnMouseDown(){
   isCharing = true;
}

function OnMouseUp(){
   isCharing = false;   
   //shoot with strenght of timer's value
   timer = 0;
}

if you want to just add a simple delay:

function Update(){
   var timer : float =  0;
   var willShoot : boolean = false;
   if(willShoot){
      if(timer<0){
      //shoot projectile
      willShoot = false;
      }
      else{
         timer -= Time.deltaTime;
      }
   }
}

function OnMouseDown(){
   if(!willShoot){
      willShoot = true;
      timer = 0.5f;
   }    
}