Game Development Community

How to Map Yaw and Pitch in Left Mouse Button

by TigerHeros · in Torque 3D Professional · 06/08/2010 (2:14 am) · 5 replies

Hi All

I want to show my cursor in the Torque 3d. I modified this statement " noCursor = "1"; " into " noCursor = "0"; " in the playGui.gui. So, now I have my cursor showing in my game. However, this bring in a new problem:

moveMap.bind( mouse, xaxis, yaw );

moveMap.bind( mouse, yaxis, pitch );

the two statements above will take no effect any more.

How can I toggle(map) my Left mouse with yaw/pitch while the cursor is showing.

Need I modify the ENGINE?

#1
06/08/2010 (5:42 am)
When you make the cursor visible, the input system cannot receive mouse inputs. You can probably use GUIs to call the yaw() and pitch() functions, however.

Place a GuiMouseEventCtrl over your PlayGui, and use the onMouseDown(), onMouseUp() and onMouseDragged() callbacks to control the view. GuiMouseEventCtrl will send 3 arguments to its callbacks: modifier ($EventModifier::LSHIFT, $EventModifier::RSHIFT, etc), GUI-relative mouse position and number of clicks (so you can detect double-clicks).

You can store the position in onMouseDown(), and on each call to onMouseDragged() you check how much the mouse has moved and call yaw() and pitch() accordingly.
#2
06/08/2010 (6:30 pm)
Could this work if you moved the buttons around?

http://www.torquepowered.com/community/forums/viewthread/111587/1#comment-731059
#3
06/08/2010 (10:49 pm)
@Manoel Thank You for you reply .

$ForwardKeyDown = 0;

function checkLeftMouseDown(%val)
{
if (%val)
{
if (Canvas.getMouseControl().getName() $= "PlayGui")
{

if (!$ForwardKeyDown)
$mvForwardAction = %val * $movementSpeed;
$LeftMouseDown = 1;
}
}
else
{
if (!$ForwardKeyDown)
{
moveForward(0);
}
else
{
$MouseDragged = 0;
canvas.cursorOn();
Canvas.setCursorPos($LastCursorPos);
}
$LeftMouseDown = 0;
}
}

when i have clicked the left mouse button i am receiving the following error.

Unable to find Object '0' attempting to call function 'getName'

if (Canvas.getMouseControl().getName() $= "PlayGui")

The above code does not take effect.

whats wrong in the code.
#4
06/15/2010 (9:27 am)
Shall i have to change in PlayGui.gui file or i have to MODIFY IN THE ENGINE SOURCE CODE.
#5
06/24/2010 (9:34 pm)
Could any One give the Proper Link (C++ engine Files) for making wow function with Left Mouse Button.

If i Click the Left Mouse Button the camera should rotate.

How can i do it?