Binding Mouse Scroller
by Todd Johnson · in Torque Game Engine · 06/20/2004 (9:26 pm) · 8 replies
How could I bind the up and down scroll on the mouse using moveMap.bindCmd?
#2
Ian
Mode 7 Games
06/21/2004 (8:16 am)
Here's an example of my use of the mousewheel. I've also put mouseWheel stuff in the moves, but that's too much c for here :) This kind of thing should do you for simple stuff though.moveMap.bind(mouse, "zaxis", handleMouseWheel);
function handleMouseWheel(%val)
{
if (%val > 0)
{
$mvMouseWheelCount ++;
}
else if (%val < 0)
{
$mvMouseWheelCount --;
}
}Ian
Mode 7 Games
#3
%val is > 0 for wheel moving "away" from the user, < 0 for wheel moving "towards" the user.
Use example:
Of course, you'll need to write the server side commands for this example.
EDIT: Lol, Ian beat me to it, but two different techniques, both work great!
06/21/2004 (8:19 am)
MoveMap.bind(mouse0, "zaxis", yourScriptCommandHere);%val is > 0 for wheel moving "away" from the user, < 0 for wheel moving "towards" the user.
Use example:
moveMap.bind(mouse0, "zaxis", AvatarCamWHeelZoom);
function AvatarCamWheelZoom(%val)
{
if ( %val < 0 )
commandToServer('CamZoomOut');
else if ( %val > 0 )
commandToServer('CamZoomIn');
}Of course, you'll need to write the server side commands for this example.
EDIT: Lol, Ian beat me to it, but two different techniques, both work great!
#4
06/21/2004 (10:10 am)
Nice job, guys! :)
#5
06/21/2004 (4:58 pm)
Hooah! Thanks!
#6
01/04/2005 (9:31 pm)
Stephen, that's a good way to do camera zooming. I might use that method for my vehicle cameras.
#7
The commandToServer portion of camera controls is not however a great technique--when I first wrote the orbit mode for the adv Cam, I was pretty inexperienced in TGE, and it was the simplest implementation. If/when I re-write that camera mode, I'll be working along the lines of how the FPS camera accepts input controls--it's much cleaner, precise, and lag-independent.
01/04/2005 (10:07 pm)
@Josh: Yeah, both the Orbit/Avatar cam mode of the advanced Camera, as well as the RTS SK use it for zoom functionality (well, the RTS SK actually uses it for controlling the height of the camera over the terrain, but it's mostly zoom in effect).The commandToServer portion of camera controls is not however a great technique--when I first wrote the orbit mode for the adv Cam, I was pretty inexperienced in TGE, and it was the simplest implementation. If/when I re-write that camera mode, I'll be working along the lines of how the FPS camera accepts input controls--it's much cleaner, precise, and lag-independent.
#8
01/05/2005 (1:25 am)
My vehilce camera is a heavily modified AdvancedCamera, before the orbit stuffwas added. I use a console method to set the offset that the camera will use. The camera smoothly follows the vehicle, and smoothly transitions from offset to offset. CommandToServer will work perfect for my needs. :)
Associate Kyle Carter