Need a little help with Mouselook/Mouse Bind
by Felyza Wishbringer · in Torque 3D Beginner · 12/22/2012 (10:38 am) · 7 replies
What I am trying to accomplish is the scroll wheel button on the mouse turning on mouselook when pressed down, and turning if off when released. Should be simple enough, I would think. I've tried several ideas from the forums, as well as other random places I've found information (such as documentation, source code, etc) and cannot seem to get this to work. I cannot seem to even get it working with RMB. Here is my current bit of code related to this..
In the above example, I've tried all of the binds in the commented out section. None of them work. Any chance one of you gurus could give me a little direction?
EDIT: The m keybind works fine, and I've tried the mouse binds without that in there.
function toggleMouseLookOn()
{
//Cursor position save will go here.
echo("button down");
hideCursor();
}
function toggleMouseLookOff()
{
//Cursor position reset will go here.
echo("button up");
showCursor();
}
function toggleMouseLook(%val)
{
if(%val) {
toggleMouseLookOn();
} else {
toggleMouseLookOff();
}
}
/*
PlayGui::onMiddleMouseDown(%this, %pos, %start, %ray)
{
GlobalActionMap.bindCmd(mouse, "button2", "toggleMouseLookOn();", "toggleMouseLookOff();");
}
PlayGui::onRightMouseDown(%this, %pos, %start, %ray)
{
GlobalActionMap.bindCmd(mouse, "button1", "toggleMouseLookOn();", "toggleMouseLookOff();");
}
moveMap.bind(mouse, "button2", "toggleMouseLook");
*/
moveMap.bind(mouse, "button1", "toggleMouseLook");
moveMap.bind(keyboard, "m", "toggleMouseLook");In the above example, I've tried all of the binds in the commented out section. None of them work. Any chance one of you gurus could give me a little direction?
EDIT: The m keybind works fine, and I've tried the mouse binds without that in there.
#2
12/22/2012 (2:34 pm)
Check out the "client/config.cs" file. Editing the "default.bind.cs" file is only the first step. The config file overwrites the binding from default.bind. You're code may be correct, but it just might be ignored.
#3
12/22/2012 (2:47 pm)
Indeed - any time you edit default.binds.cs you should ensure that config.cs DOES NOT EXIST before running the game again. The engine generates a "compiled" version of default.binds and saves it in config.cs - if config.cs exists default.binds is ignored.
#4
Caleb and Richard Ranft, I do not have a copy of config.cs anywhere in the project tree, let alone project/game/scripts/client. 'Grepping' the project tree, the only instances of button2 (which common sense tells me should be Mouse 3/Scroll Wheel Button/Middle Mouse) are in the default.bind.cs and found in the code in the original post in this thread.
If it helps, using Torque3D-master from Github, retrieved 12/19.
12/22/2012 (6:21 pm)
Britt Scott, I am planning on using an orbitCam much like in the RTS Prototype tutorial. It is a third-person perspective centered on the player; think like the Diablo franchise, Sacred 1&2, etc. Looking for (eventually) smart-chase as well as user controlled. Caleb and Richard Ranft, I do not have a copy of config.cs anywhere in the project tree, let alone project/game/scripts/client. 'Grepping' the project tree, the only instances of button2 (which common sense tells me should be Mouse 3/Scroll Wheel Button/Middle Mouse) are in the default.bind.cs and found in the code in the original post in this thread.
If it helps, using Torque3D-master from Github, retrieved 12/19.
#6
Hmm, looks like I have to install yet another version of T3D on my system so I can keep up with all of the questions!
And to hand you a slight shortcut (Taras' link takes you to one thread but that thread links to the solution in another) here's a direct link to a thread with a source edit that will help. Dave Wyand posts a quick engine fix to allow mouse events even when the cursor is hidden.
Between those two threads hopefully you can get this working the way you want.
01/02/2013 (3:29 pm)
Actually, that does help (me) - I haven't actually looked at T3D MIT yet, so I apologize that my advice is in error. Sounds like they might have eliminated the config.cs write - a good thing.Hmm, looks like I have to install yet another version of T3D on my system so I can keep up with all of the questions!
And to hand you a slight shortcut (Taras' link takes you to one thread but that thread links to the solution in another) here's a direct link to a thread with a source edit that will help. Dave Wyand posts a quick engine fix to allow mouse events even when the cursor is hidden.
Between those two threads hopefully you can get this working the way you want.
#7
Richard, that source was a great spot to head to. Looks like the code changes were already applied, so I just needed to set this in Canvas creation in main.cs:
Then I accomplished my camera with this added to the end of playGui:
Going to add save and reset of camera, but it will suffice for now. Thank you for your help. Back to making art assets. I have a feeling I'm going to be working on art assets a long time, until I start getting better at it.
01/07/2013 (11:39 am)
Taras, your code suggestion had no effect. Richard, that source was a great spot to head to. Looks like the code changes were already applied, so I just needed to set this in Canvas creation in main.cs:
Canvas.alwaysHandleMouseButtons=1;
Then I accomplished my camera with this added to the end of playGui:
function PlayGui::onMiddleMouseDown( %this )
{
commandToServer('orbitCam');
hideCursor();
$mvFreeLook = true;
}
function PlayGui::onMiddleMouseUp( %this )
{
showCursor();
$mvFreeLook = false;
}Going to add save and reset of camera, but it will suffice for now. Thank you for your help. Back to making art assets. I have a feeling I'm going to be working on art assets a long time, until I start getting better at it.
Associate Britt Scott
I went to scripts/client/default.bind.cs
This only works in 3rd person view...?