Simple Camera problem
by Jacob Wood · in Torque Game Engine · 11/01/2006 (6:35 am) · 4 replies
I'm simply getting an in-game menu to pop-up when you press escape, and go away when you hit it again. I've already got it working just fine but for some reason I can't get the camera to go back to adjusting the pitch and yaw of the player. It just locks in place when the game loads up. The player still goes forward, backward, strafe left and strafe right though. I've also noticed that once I start, I can't shoot either until I hit escape to biring the menu up, and hit it again to make it disappear.
I simply made a new gui in the torque gui editor and then had it appear and disappear in code by binding the command to the escape keystroke.
Here's the toggle code:
So basically, I just want the pitch and yaw controls to work when the escape menu pops up, and stop working when it goes away. It sounds like a simple fix but for some reason I can't figure it out. I'd appreciate any input, thanks.
I simply made a new gui in the torque gui editor and then had it appear and disappear in code by binding the command to the escape keystroke.
Here's the toggle code:
$inGameMenuToggle = !$inGameMenuToggle;
if($inGameMenuToggle){
Canvas.pushDialog(inGameMenu);
Canvas.cursorOn();
}
else
{
Canvas.popDialog(inGameMenu);
Canvas.cursorOff();
}So basically, I just want the pitch and yaw controls to work when the escape menu pops up, and stop working when it goes away. It sounds like a simple fix but for some reason I can't figure it out. I'd appreciate any input, thanks.
#2
11/06/2006 (8:01 am)
My main problem right now is that I can't trace the actual implementation of the mouse control over the camera in code. Is it a C++ function that I'm not supposed to mess with? Maybe there's a resource on keybinding and how they actually work in the engine?
#3
First off there is the script piece, this is where key binding is done and input is relayed to the C++ portion of the code. You can usually find this code in the "default.bind.cs" script file. It will have several moveMap bindings and helper functions. The movemap bindings tell the engine which script functions to execute on mouse and keyboard input. The helper functions then take that input and realy it to the appropriate place in the engine. In stock TGE this is done through manipulating $mv* vairiables(in your case look at the functions that manipulate $mvYaw adn $mvPitch).
This leads us to the second half of the controls in TGE which is the MoveManager portion of GameConnection (found in the MoveManager.h and GameConnectionMoves.cc files). During consoleinit several global console/script variables are created. During the game loop these variables are polled (via curMove function in GameConnectionMoves.cc) and passed to the control object (via processTick and interpolateTick) set in the appropriate client connection object (Instance of GameConnection C++ object). Make sure your GameConnection object gets a Control and Camera object (on the server not the client). Usually this is done through the GameConnection::onClientEnter (double check this as I'm at work right now. It's in the games.cs file in tutorial base). The processTick and interpolateTick methods actually take that input and apply it to the position of the objects in game. In your case look through Player.cc and Camera.cc for their processTick and interpolateTick functions, or the appropriate classes representing the control object your setting on your Game Connection. These functions take a little bit to grok as they also take care of client side prediction (delta variables).
This is all predicated on binding functions getting the mouse and keyboard input. With cursor on I dont' think mouse input will be relayed to the movemap functions. It sounds like your problem is either with that or not properly setting up your moveMap bindings which is somehow fixed in your dialog or cursrorOn/Off.
Hope that helps you troubleshoot.
11/06/2006 (9:46 am)
I just spent the weekend getting the camera set up for my project so I can shed some light on how the controls get to the camera.First off there is the script piece, this is where key binding is done and input is relayed to the C++ portion of the code. You can usually find this code in the "default.bind.cs" script file. It will have several moveMap bindings and helper functions. The movemap bindings tell the engine which script functions to execute on mouse and keyboard input. The helper functions then take that input and realy it to the appropriate place in the engine. In stock TGE this is done through manipulating $mv* vairiables(in your case look at the functions that manipulate $mvYaw adn $mvPitch).
This leads us to the second half of the controls in TGE which is the MoveManager portion of GameConnection (found in the MoveManager.h and GameConnectionMoves.cc files). During consoleinit several global console/script variables are created. During the game loop these variables are polled (via curMove function in GameConnectionMoves.cc) and passed to the control object (via processTick and interpolateTick) set in the appropriate client connection object (Instance of GameConnection C++ object). Make sure your GameConnection object gets a Control and Camera object (on the server not the client). Usually this is done through the GameConnection::onClientEnter (double check this as I'm at work right now. It's in the games.cs file in tutorial base). The processTick and interpolateTick methods actually take that input and apply it to the position of the objects in game. In your case look through Player.cc and Camera.cc for their processTick and interpolateTick functions, or the appropriate classes representing the control object your setting on your Game Connection. These functions take a little bit to grok as they also take care of client side prediction (delta variables).
This is all predicated on binding functions getting the mouse and keyboard input. With cursor on I dont' think mouse input will be relayed to the movemap functions. It sounds like your problem is either with that or not properly setting up your moveMap bindings which is somehow fixed in your dialog or cursrorOn/Off.
Hope that helps you troubleshoot.
#4
I had also tried turning off the cursor off when the dialog goes away, didn't work.
Anyway, I guess for now the best way to fix it is to do my best to avoid screwing with the playgui too much :P
11/30/2006 (6:53 pm)
Thanks for your input Craig. Sorry for the delayed reply. I was just doing my best to work around the problem. What worked best for me was to slowly overwrite the gui files with the original starter.fps ones until the problem fixed. I had also tried turning off the cursor off when the dialog goes away, didn't work.
Anyway, I guess for now the best way to fix it is to do my best to avoid screwing with the playgui too much :P
Torque Owner Robert Seeman
I made a few changes to PlayGui.gui and saved it. Now whenever PlayGui is opened, the mouse cursor shows and I have no control using the mouse. I have to bind Canvas.cursorOff(); to a keymap to get control back. If I hit ~ to view the console then hit ~ again, the mouse cursor is back!
I tried adding Canvas.cursorOff(); to PlayGui::OnWake() but this does not resolve the issue.
I'd be interested to learn if someone has some insight as to why this is happening. I have not been able determine what the source of the issue is.
-Robert