How to detect mouse movement as an input

Hi all,
I am in the process of converting a project from keyboard only input to keyboard and mouse input. The keyboard is used for vertical and horizontal movement, and the mouse is used for rotation. This is for 2.5d game where rotation only occurs on the X axis.
I can get the player object to rotate to follow the mouse already using a raycast from the camera to the mouse pointer. My question is this however:

How can I use a change in the mouses position (i.e if the mouse moves left) to initiate an action. So in pseudo code basically what I am trying to do is this (in UnityScript not C#):

if (Mouseposition moves left)
{
   initiate actions;
}

I should mention that I have tried using a variable that compares the initial vector3 position of the mouse (which is updated every 0.1 seconds) with the current position of the mouse but to no avail.
The reason I want to do this is so I can use AddTorque rather than transform.Rotate
I’ve been toying around with this for a couple of hours now and it’s got me stumped. :frowning:

Any Input would be greatly appreciated. I’m not asking for code, just help with the logic I will need for this.

If I understood you correctly you can simply use:

if(Input.GetAxis("Mouse X")<0){
    //Code for action on mouse moving left
    print("Mouse moved left");
}
if(Input.GetAxis("Mouse X")>0){
    //Code for action on mouse moving right
    print("Mouse moved right");
}

bool HasMouseMoved()
{
//I feel dirty even doing this
return (Input.GetAxis(“Mouse X”) != 0) || (Input.GetAxis(“Mouse Y”) != 0);
}

That’s what I’ve used but I wonder if there’s a more efficient way to get the axis than passing in a string? Seems very clunky.

OMG! You have no idea how finding this made my week. Yes WEEK. I have a boat controller and when I turn I wanted it to bank into the turn to look more realistic. The code I had worked
transform.Rotate(0, 0, -(Input.GetAxis(“Mouse X”)) * Time.deltaTime * speed );

but after a few turns left and right , when going straight the boat would still be tilted so spent tons of hours trying to figure out how to right the boat. Storing temp rotation values, animating the bank and trying to trigger those. 3 very long days of failure but THIS!!! this is so simple. If I am steering, the boat banks, if I am not steering, it slerps back to default. THANKS SO MUCH for this amazingly simple yet life saving info

using UnityEngine;
using System.Collections;

public class boatBank : MonoBehaviour {
	//this script goes on a child object(boat) of the main gamobject
	public float speed = 4f;
	public Transform target;//this a child of the main gameobject with same transforms as boat default position this script does not effect it
	public float damping = 2f;

	void Start () {
	}

	void Update () {
		
		if(Input.GetAxis("Mouse X")<0)
		{
			transform.Rotate(0, 0, -(Input.GetAxis("Mouse X")) * Time.deltaTime * speed );
			print("Mouse moved left");
		}
	else if(Input.GetAxis("Mouse X")>0)
		{
			transform.Rotate(0, 0, -(Input.GetAxis("Mouse X")) * Time.deltaTime * speed );
			print("Mouse moved right");
		}
		else  
		{
			var rotation = Quaternion.LookRotation(target.position - transform.position);
			transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
			print("boat straightening out");
			
		}
		
	}
}

Hey Guys can you help me, i am stuck while making my first : First player shooter, i am not able to rotate my screen. i used In
Input.GetAxisRaw(Mouse X)
but i am getting 0 ,0,0 as the output