How do I get the mouse sensitivity setting in code?
The reason I need this value is that I’m moving an object with the mouse along a grid.
I want the object to move a number of grid squares equal to mousedelta * squarewidth / sensitivity.
The problem is that if I use a static value it will skip squares if the user sets the value too low.
If there isn’t a way to do this any other suggestions would be appreciated.
these guys are correct. multiply the mouse input axis with a speed float to change sensitivity. of course you did that you would need to hide the actual mouse in the game and use your own.
a mouse skipping over positions is a problem that can happen even without changing sensitivity.
here is some code i wrote to get skipped mouse positions:
public Vector2[] missed;
int i;
float maxmove;
Vector2 direction;
public Vector2 mouse;
Vector2 oldmouse;
float distance;
string txt;
void Start () {
oldmouse = Input.mousePosition;
maxmove = 10f;//<--------max allowed distance between pixels
}
// Update is called once per frame
void Update () {
mouse = Input.mousePosition;
direction = mouse - oldmouse;
distance = direction.magnitude;
//check if mouse has moved more distance than maxmove
if (distance > maxmove) {
//get the amount of locations we missed
i=Mathf.FloorToInt(distance/maxmove);
i=i+1;
//get the step in direction
direction =new Vector3(direction.x/i,direction.y/i);
txt="missing points: ";
i=i-1;
missed = new Vector2*;*
while(i>0){i--;*
//add direction in steps to fill missing positions*
int i2=i+1;*
missed_=directioni2; missed=missed+oldmouse; txt=txt+missed+" "; //do stuff here to missing positions; //or i also put them into an array for you* * }*_
* print (“mouse moved from “+oldmouse+” to “+mouse+” distance:”+distance);* * print (txt);* * }* * oldmouse=mouse;*