Reading *NO* input from the mouse...

Hey all,

It's been a while since I've needed to ask any questions here...mostly due to the fact that every other time has resulted in an answer that has helped me on my way..but I'm back.

Is there a way to read no input from the mouse? Basically my controls are based around mouse movements...when the mouse hasn't been moved for..say 3 seconds, it would automate the character movement (via a predefined pathway, no issues with this)...sooo, how do I read no input?

Hope that is succinct enough.

Thanks in advance,

Russ.

The basic idea is that you have a `timer` and whenever the mouse is moving reset it. If you are over your `time-out` then it's time do something. Here is the code:

var timeOut: float = 3.0;
private var timer: float = 0.0;

function Update () {
    timer += Time.deltaTime;
    if (Input.GetAxis("Mouse X") || Input.GetAxis("Mouse Y")) {
        timer = 0.0;
    }
    if (timer > timeOut) {
        //Do Something awesome when there is a time out
    }
}

Hey, I needed to do a mouse detection to automatically fade a gui (ie. after a few seconds, if there was no mouse input, fade down) so I guess similar principles could be applied.

The idea is that you are comparing the mouse position with the mouse position from a few seconds ago in order to see whether it has changed. If it hasn't changed, then MouseIsMoving is false. It was important to use Mathf.Round to clean up the positions.

Essentially, the important thing here is MouseIsMoving boolean, which will give you your final mouse detection script. Hope this helps!

static var fade : float = 0.0;
static var MouseIsMoving : boolean;
private var DelayMousePos : Vector3;
private var CurrentMousePos : Vector3;

function FixedUpdate(){
DelayMousePos = Vector3.Lerp(DelayMousePos, CurrentMousePos, Time.deltaTime/0.5);
CurrentMousePos = Input.mousePosition;
var DelayMousePosClampX = Mathf.Round(DelayMousePos.x);
var DelayMousePosClampY = Mathf.Round(DelayMousePos.y);
var DelayCorrected = Vector3(DelayMousePosClampX, DelayMousePosClampY, DelayMousePos.z);

if(CurrentMousePos == DelayCorrected){
    MouseIsMoving = false;
    }
    else{
    MouseIsMoving = true;
    }

}