While this works, I notice it’s not consistent. If I count the amount of Mouse Counts to do a horizontal 360 spin on chrome, and execute the same amount of Mouse Counts in Firefox (and Edge), it does a bit more than a 360 spin. I also notice a difference in Stand-alone builds.
Does anyone know how to get pure mouse input, which is consistent across all browsers? No mouse acceleration, no smoothing, … just plain raw mouse input.
You’d probably do something like this: (I’m not at my normal dev pc so haven’t tried this)
Vector3 LastPosition;
void Update()
{
Vector3 CurrentPosition = Camera.main.ScreenToViewportPoint(Input.mousePosition);
Vector3 DeltaVec = CurrentPosition - LastPosition;
LastPosition = CurrentPosition;
// Multiply DeltaVec by a value to make it more sensitive
DeltaVec *= 50.0f;
// Wherever you were using 'Input.GetAxisRaw("Mouse X")' in your code you can now
// use DeltaVec.x
// Wherever you were using 'Input.GetAxisRaw("Mouse Y")' in your code you can now
// use DeltaVec.y
}
Thanks, this makes sense and I understand it better now. But will this still work with a locked cursor? I lock the cursor so it won’t move on full screen mode.
Ah, I’m not sure about that - it would probably just return you the same value each time in that case.
The code you originally had should work though, I’m not sure why it doesn’t as the GetAxisRaw should return the same value on each browser. Perhaps the game is just running at a different speed in each browser and that’s why you’re getting different results. You could try running the code in FixedUpdate rather than Update perhaps?
Did some testing: the values GetAxisRaw returns are not just -1, 0 or 1. It seems like for mouse input, there’s not difference between GetAxis and GetAxisRaw. Could this be causing the issue?
I was going to mention that. I recently tried using Raw in some code and noticed the same thing.
I’d say try: Time.deltaTime * amountPerSecond * GetAxis and call it a day.
You could create your own ‘Raw’ value, not sure if that’s helpful or not.