Game Development Community

Help me

by Michael S · in Torque Game Builder · 10/10/2006 (5:21 am) · 6 replies

How to set cursor speed so it won't move too fast

here is my current script

// my bee position = my mouse position but if i play the mouse move too fast
//and if you moving your mouse around the bee 's movement is shaking and not move smoothly
//can you help me to solve this problem

function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{

$nx=(getword(%worldPosition,0));
$ny=(getword(%worldPosition,1));

if (mybee.getflipx()==true && $nx>mybee.getpositionx())
{mybee.setflipx(false);}
else if (mybee.getflipx()==false && $nx {mybee.setflipx(true);}

mybee.setPosition(%worldposition);

}


thanks a lot

#1
10/10/2006 (9:54 am)
I'm not sure whether mybee is a sprite or a particle effect. I tried (a while back) to attach a particle effect to the cursor, but experienced the same problems as you. Nothing I did with the particle solved the problem; so I eventually gave up.

It seems to me that the easiest solution to your problem would be to make mybee be the cursor. Something like this:

if(...) Canvas.setCursor("CursorMybeeNotflipped");
else(...) Canvas.setCursor("CursorMybeeFlipped");

//And then define custom Profiles

   new GuiCursor( CursorMybeeNotflipped )
   {
      hotSpot = "1 1";
      renderOffset = "0 0";
      bitmapName = "~/data/images/GUI/MybeeNotflipped";
   };

   new GuiCursor( CursorMybeeFipped )
   {
      hotSpot = "1 1";
      renderOffset = "0 0";
      bitmapName = "~/data/images/GUI/CursorMybeeFipped";
   };

Obviously, you don't get any animations or particle effects; but these could be triggered during the change of cursors.
#2
10/10/2006 (11:35 am)
A better option (imho) would be to move the bee to the cursor, rather than setPosition() it.

function SceneWindow2D::onMouseMove(%this, %mod, %worldPosition)
{ 

$nx=(getword(%worldPosition,0));
$ny=(getword(%worldPosition,1));
[b][i]$beeDist = vectorDist($nx SPC $ny, mybee.getPosition);   // get distance from bee to cursor[/i][/b]

if (mybee.getflipx()==true && $nx>mybee.getpositionx())
{mybee.setflipx(false);}
else if (mybee.getflipx()==false && $nx<mybee.getpositionx())
{mybee.setflipx(true);} 

}

[b][i]function SceneWindow2D::onUpdateScene(%this)
{
// bee velocity will be a function of distance to cursor
// this provides free ease-in/ease-out
// placed in onUpdateScene so that velocity will update
// Alternately, place in a relatively short looping schedule
mybee.moveTo($nx SPC $ny, $beeDist);

}[/i][/b]

edit: Emphasised my changes/additions
#3
10/10/2006 (7:02 pm)
Hmm i found this quick answer in the last thread topic about "mouse way too sensitive"

In ..\client\scripts\default.bind.cs
find

...
function getMouseAdjustAmount(%val)
{
// based on a default camera fov of 90'
return(%val * ($cameraFov / 90) * 0.01);
}
...

To make the mouse less sensitive change the 0.01 to 0.008 or so.


but i don't found file default.bind.cs in my torquegamebuilder folder
where can i find that file ?
#4
10/10/2006 (7:11 pm)
Michael, that refers to TGE, not TGB.
#5
10/10/2006 (7:11 pm)
Wow thanks a lot teck lee tan . that's magic it really work.
but i still curious about

my previous post

In ..\client\scripts\default.bind.cs
find

...
function getMouseAdjustAmount(%val)
{
// based on a default camera fov of 90'
return(%val * ($cameraFov / 90) * 0.01);
}
...

To make the mouse less sensitive change the 0.01 to 0.008 or so.

i didn't found file named default.bind.cs
hehehehehhe
#6
10/10/2006 (7:12 pm)
Upssss my mistake .thank you anyway