2D Mouse Controls

Hi I am working on a 2D Sidescroller I got the Keyboard controls working however I wanted to test now how the game would be playable with mouse controls, but I can’t figure out how to get these working.
The idea behin it is that the player ship can only move in the current camera viewport. If i move my mouse to the left the ships flies to the left etc.

here is my script for keyboard controls

var playerSpeed : int;
var xOff : float;
var yOff : float;

function Update () {

// amount to move Player
xOff += (playerSpeed * Input.GetAxis("Horizontal")) * Time.deltaTime;
yOff += (playerSpeed * Input.GetAxis("Vertical")) * Time.deltaTime;

// restrict player to camera position
if (xOff > Camera.main.orthographicSize * Camera.main.aspect)
{	xOff = Camera.main.orthographicSize * Camera.main.aspect;
}

if (xOff < -Camera.main.orthographicSize * Camera.main.aspect)
{	xOff = -Camera.main.orthographicSize * Camera.main.aspect;
}

this.transform.position.x = Camera.main.transform.position.x + xOff;
this.transform.position.y = Camera.main.transform.position.y + yOff;

if (yOff > Camera.main.orthographicSize)
{	yOff = Camera.main.orthographicSize;
}

if (yOff < -Camera.main.orthographicSize)
{	yOff = -Camera.main.orthographicSize;
}
}

function OnTriggerEnter (collisionInfo : Collider) {
if (collisionInfo.gameObject.tag == "Enviroment"){
	Destroy(gameObject);
	}
}

is there any simple solution to just change the keyboard input to mouse input ?

If you just replace “Vertical” and “Horizontal” by “Mouse Y” and “Mouse X” it should work - but a slower speed, since the mouse axes return small values near to 0 (restricted to the range -1…1) proportional to the mouse displacement since last Update, while the keyboard returns -1 or 1 while the keys are pressed. You can increase the playerSpeed to compensate this, but at some point the movement may become somewhat jerky, since the values returned by the mouse axes vary a lot.

NOTE: Mouse Y runs to the opposite side compared to Vertical, thus you must subtract it from yOff to have the same results.