accelometer slight shake

Hi, folks!

Ive got problem - i cant get accelometer control as i want… Currently, im using this script that makes sure that im shaking the device, BUT the problem is I dont need to shake so hard to get my anticipated outcome. I want to detect a shake that is not so “heavy”, i want to detect shake as it is almost just a device movement, BUT without any rotation measurement.

Could someone help me out? im fighting this one for a long time - this one is a huge struggle for me.

Thanks in advance!

var speed = 15;
var toolScr:_ButtonOldCheck;
static var canMoveForward:boolean=true;
static var canMoveBackward:boolean=true;
var moveTreshold: float=0.1;
private var xAcc: float=0.0;

private var accelerometerUpdateInterval : float = 1.0 / 60.0;
private var lowPassKernelWidthInSeconds : float = 1.0;
private var shakeDetectionThreshold : float = 2.0;

private var lowPassFilterFactor : float = accelerometerUpdateInterval / lowPassKernelWidthInSeconds; 
private var lowPassValue : Vector3 = Vector3.zero;
private var acceleration : Vector3;
private var deltaAcceleration : Vector3;

private var myTransform: Transform;
private var shakeControl: boolean=true;

function Start()
{
	if(Application.loadedLevel==5) this.enabled=false;
	
	canMoveForward=true;
	canMoveBackward=true;	
	
	myTransform= transform;
    shakeDetectionThreshold *= shakeDetectionThreshold;
    lowPassValue = Input.acceleration;
    
 	
}

function Update () 
{
	var currTool:String=toolScr.oldObj.name;
	
	if(currTool=="tool4"&&shakeControl)
	{
		acceleration = Input.acceleration;
		lowPassValue = Vector3.Lerp(lowPassValue, acceleration, lowPassFilterFactor);
		deltaAcceleration = (acceleration - lowPassValue);
    
    	if (deltaAcceleration.sqrMagnitude >= shakeDetectionThreshold)
    	{
    		//print(acceleration);
    		var zCord: float;
    		//var currentAccX: float=deltaAcceleration.x;
    		var currentAccX: float=acceleration.x;
    		
       		if(canMoveForward&&canMoveBackward)
       		{
       			zCord=Mathf.Lerp(0,currentAccX,Time.time);
       			myTransform.Translate(0,0,zCord*Time.deltaTime);
       		}	 
       		if(!canMoveForward &&acceleration.x<0)
       		{
       			zCord=Mathf.Lerp(0,currentAccX,Time.time);
       			myTransform.Translate(0,0,zCord*Time.deltaTime);
       		}	
       		if(!canMoveBackward &&acceleration.x>0) 
       		{
       			zCord=Mathf.Lerp(0,currentAccX,Time.time);
       			myTransform.Translate(0,0,zCord*Time.deltaTime);
       		}	
   		}
	
	}
	
function ChangeAccMode()
{
	shakeControl=!shakeControl;	
}

Try the following :

var shakespeed = AccelerometerValues /10;

use this to lower your values and decrease the sensitivity of you app. The acceleromter istelf might be read-only, but if you declare a variable which is saving the input value, you can divide it by a certain number to virtually “lower” the sensitivity of your accelerometer