Im trying to make an RTS camera that would pan in the direction of the mouse instead of an axis

For starters the code

private float camerapanspeed = 10f;
private float MousePositionX;
private float MousePositionY;
private float MouseOffsetX;
private float MouseOffsetY;

// Use this for initialization
void Start () {



}

// Update is called once per frame
void Update ()
{

	MousePositionX =Input.mousePosition.x - Screen.width / 2;
	MousePositionY =Input.mousePosition.y - Screen.height / 2;
	MouseOffsetX = MousePositionX / 100
	MouseOffsetY =

	if (Input.mousePosition.x > Screen.width - 50 | Input.mousePosition.x < 0 + 50 ) {
		transform.Translate (Vector3.right * MousePositionX * Time.deltaTime , Space.World);
		transform.Translate (Vector3.forward * MousePositionY *Time.deltaTime , Space.World);

This is a part that manages the camera pan on right and left side of the screen moving it both horizontaly and verticaly depending on how high the cursor is on the Y axis of the screen measured from the middle.

I cant find a way that would allow me to make the camera move at a specific speed of my chosing.

You could fire a ray in the center of the camera, and then a ray through the mouse position, get the difference of the vectors and ignore the y component

Though this would work best for a flat terrain