Game Development Community

dev|Pro Game Development Curriculum

Smooth mouse movement

by Sean H. · 04/05/2010 (10:14 pm) · 3 comments

This script resource slightly modifies mouse movement in a way which I've found to be much smoother than the stock mouse movement. This modification is applicable for every torque 3d engine from TGE to T3D.(possibly TorqueX as well)

This is super simple. Open up default.bind.cs and find this line near getMouseAdjustAmount(%val):

return(%val * ($cameraFov / 90) * 0.01)

and change 0.01 to mabs(0.00018*%val)

return(%val * ($cameraFov / 90) * mabs(0.00018*%val))

What this is doing is introducing a linear function which acts as a smoothing factor. I did a simple slope calculation to arrive at the value 0.00018. For small mouse movements(input), the output will be small, for larger inputs, the mouse movement will scale accordingly. The factor 0.00018 can be slightly adjusted to be higher for steeper slope(faster mouse), or lowered for a more gradual slope(slower mouse).

For T3D, you can either leave $pref::Input::LinkMouseSensitivity as a factor of the result, or it can possibly instead be used as a factor modifying the slope factor: 0.00018.

Try it out and let me know what you think.



#1
04/06/2010 (7:10 am)
A ) is missing at the end.

It works. Very good.

What i like is a indirect steering of the mouse like HL2 has. Any ideas?
#2
04/06/2010 (9:12 am)
So this is saying that the mouse will gradually increase speed until it hits a hard limit and It will hit that hard limit faster if you move your mouse faster?

Or are you saying that the mouse movement is a constantly changing variable based on mouse speed with no max or hard limit?
#3
04/06/2010 (5:15 pm)
Thanks Thomas. Glad it's working for you.

There's a few resources for vehicle control using the mouse. I've never looked into this myself.

@Zergcow - theres no limit or cap on how fast the mouse will move, although that wouldn't be hard to implement.

some will find the 0.00018 factor makes the mouse move too quickly for large mouse movements. I would suggest playing around with the value. Mouse sensitivity can then be configured by mapping to a range of mouse "slope" values.