Game Development Community

Can we set Mouse Speed ???

by Michael S · in Torque Game Builder · 10/27/2006 (4:13 am) · 12 replies

Hi all , i've stumbled in how we can set the mousespeed in TGB?so
we can move mouse slower / faster like we want
is there any idea ?

#1
10/28/2006 (1:25 am)
Can we set mouse's cursor speed in TGB or can't?
i looked for this question on other forum but there is no answer

thanks
#2
10/28/2006 (12:49 pm)
You can set the mouse position and you can get the mouse position...should be enough to write something useful. What kind of effect are you going for?
#3
10/30/2006 (4:48 am)
Hmm i want if i move my mouse , the cursor move not too fast.
this is like where we go to control panel and we can set up our mouse speed.
thanks tom for the reply
#4
10/30/2006 (11:33 am)
Depending on what you're working on, you could see how far the mouse has moved since the last frame and then set its position to somewhere between where it was last frame and this frame depending on the time elapsed.

There are probably resources somewhere that cover this.
#5
10/30/2006 (7:11 pm)
Thanks tom i'll try to analyze your idea
hmm maybe could somebody give me the link of the resource /complete resource about mouse based game?
thanks
#6
10/31/2006 (9:08 pm)
Hmm tom how do we know the frame in TGB?
#7
11/01/2006 (10:40 am)
Hmm... you want to change mouse sensitivity generally on entire screen?

The frame could be called by onUpdateScene(%this) func. Or you can track the mouse movement on onMouseMove() handler. And try with setMousePosition(%worldX, %worldY).
#8
11/02/2006 (7:44 am)
Check the TDN tutorial on mouse objects. You can find the code there for how to enable mouse control on objects or modify it to work on the scene as a whole. Don't forget to check the TDN reference on t2dSceneWindow as well. The API calls for mouse movement are there. Tom's original suggestion is still the best thing to do if you don't want to touch engine code.

// pseudo code to slow mouse movement by half
float scaleFactor = 0.5;
vector currentPosition = mouse.position
vector mouseDelta = vectorSub(currentPosition - lastPosition)
vector newDelta = vectorScale(mouseDelta, scaleFactor)
vector newMousePosition = vectorAdd(newDelta, lastPosition)
lastPosition = newMousePosition // stores in a globally accessible vector var
#9
11/03/2006 (1:58 am)
Hmm ok i'll try it thanks ben
#10
11/03/2006 (4:55 am)
Hmm ben should i need TGE to run that API mouse code??
#11
11/04/2006 (7:47 am)
No. There is a TGB quick tutorial on TDN about moving objects with the mouse. The API calls I'm talking about are linked to t2dSceneWindow which is not in TGE.
#12
11/05/2006 (5:10 am)
Hmm i think i got it thanks ben , and sorry for all trouble for crossposting