Using the mouse in World
by Mitchell · in Torque Game Engine · 10/10/2007 (10:05 am) · 4 replies
I'm trying to enable the mouse cursor to act like it would in a GUI when in a mission, instead of moving a POV in 3rd or 1st person.
Is there a programmatic way of doing so? I've already created a GUI and want to click my buttons I've created, but my mouse is moving about in FPS mode (meaning, it's moving the camera.)
Thanks.
Is there a programmatic way of doing so? I've already created a GUI and want to click my buttons I've created, but my mouse is moving about in FPS mode (meaning, it's moving the camera.)
Thanks.
#2
Yeah, I'm still learning. I'm now trying to tie in a reference from the scripting system that points to some C++ code global objects.
Where are the starter scripts?
10/10/2007 (2:19 pm)
Ah, thanks, that was helpful! Simple solutions are best. (Although I'd prefer a switch as opposed to holding the m key, but thanks!)Yeah, I'm still learning. I'm now trying to tie in a reference from the scripting system that points to some C++ code global objects.
Where are the starter scripts?
#3
I'd added this to the end of my default.bind.cs file and made sure it recompiled when I relaunched the engine. My only problem now is the cursor snaps back to the center after moving the mouse when it re-appears... which is very annoying. Any ideas on how to fix that?
10/20/2007 (8:10 am)
I had that problem too initially, where I had to hold down the button to get the cursor to appear. Then suddenly it just worked so I left it...function keycursor(%val)
{
if(%val)
{
if(Canvas.isCursorOn())
CursorOff();
else
CursorOn();
}
}
moveMap.bind( keyboard, m, keycursor);I'd added this to the end of my default.bind.cs file and made sure it recompiled when I relaunched the engine. My only problem now is the cursor snaps back to the center after moving the mouse when it re-appears... which is very annoying. Any ideas on how to fix that?
#4
So this does what I want it to do, added at the end of default.bind.cs
Hope it helps.
10/20/2007 (9:12 am)
Woot. I figured it out. Turns out I needed to use the Canvas cursor position not the cursor cursor position... it takes time figuring this mess out :PSo this does what I want it to do, added at the end of default.bind.cs
function keycursor(%val)
{
if(%val)
{
if(Canvas.isCursorOn())
{
$cursorLoc = Canvas.getCursorPos();
CursorOff();
}
else
{
CursorOn();
Canvas.setCursorPos($cursorLoc);
}
}
}
moveMap.bind( keyboard, m, keycursor);Hope it helps.
Employee Michael Perry
ZombieShortbus
In common\client\cursor.cs:
// These functions are already written[/b] $cursorControlled = true; function cursorOff() { if ( $cursorControlled ) lockMouse(true); Canvas.cursorOff(); } function cursorOn() { if ( $cursorControlled ) lockMouse(false); Canvas.cursorOn(); Canvas.setCursor(DefaultCursor); }[b]Place the following inside of your default.bind.cs script:
function toggleMouse() { if(Canvas.isCursorOn()) CursorOff(); else CursorOn(); } moveMap.bind(keyboard, "m", toggleMouse);All of this has been written in the scripts, just maybe not in your game's scripts.