[2D] [C#] Shoot projectile in mouse direction from player position

Hi guys, I’m trying to make a simple 2D shooter, and I need to shoot a projectile from player position to the mouse pointer position.
I did this, but it works only if the player is in the center of the world and the projectile speed changes depending of the distance between the click and the player position while I need always the same speed.

using UnityEngine;
using System.Collections;

public class ProjController : MonoBehaviour {
	
	public KeyCode shoot;

	// Use this for initialization
	void Update () {
	
		if (Input.GetKey (shoot)) {


			Vector2 mp = new Vector2 (Input.mousePosition.x,Input.mousePosition.y);
			Vector3 wp = Camera.main.ScreenToWorldPoint(new Vector3(mp.x, mp.y, 0f));

			rigidbody2D.AddForce (new Vector2(wp.x, wp.y), 0);

				}
	}

	void OnTriggerEnter2D(Collider2D other) {
		if (other.gameObject.name == "enemy") {
						Destroy (other.gameObject);
				}
		if (other.gameObject.name == "player") {
						Destroy (this.gameObject);

Try this:

void Update () {

    if (Input.GetKey (shoot)) {
        Vector3 sp = Camera.main.WorldToScreenPoint(transform.position);
        Vector3 dir = (Input.mousePosition - sp).normalized;
        rigidbody2D.AddForce (dir * amount);

     }
}

…where ‘amount’ is either replaced by a constant or is a variable you define and initialize. I’d start with a larger number…say 500 to start. I’m not sure about the 2D physics calculations, but for 3D with a mass of 1.0, 500 is about the minimum of a one-time shot to get a projectile moving reasonably.

And @meat5000’s reference is a good thing to read. You don’t need to split up and recombine vectors.