Disable InputMap on Command [SOLVED]
by Aaron Scovel · in Torque X 2D · 09/11/2010 (9:09 am) · 4 replies
I'm trying to disable the InputMap in the MovementComponent when I switch to a GUI that has a new InputMap during pause. The reason I have a problem is because the MovementComponent's InputMap and ProcessTick are still active during pause (Game.Instance.Engine.GameTimeScale = 0;) and it actually still changes variable values, even when its not visible on screen.
After a whole evening of research & digging, I found: Push and Pop
InputManager.Instance.PushInputMap(inputMap);
InputManager.Instance.PopInputMap(inputMap);
Basically, what I understand of these is that they will register(push) and disable(pop) the InputMap of choice.
If I run the Pop code inside _SetupInputMap like this...
After a whole evening of research & digging, I found: Push and Pop
InputManager.Instance.PushInputMap(inputMap);
InputManager.Instance.PopInputMap(inputMap);
Basically, what I understand of these is that they will register(push) and disable(pop) the InputMap of choice.
If I run the Pop code inside _SetupInputMap like this...
private void _SetupInputMap(TorqueObject player, int playerIndex, String gamePad, String keyboard)
{
//All the normal input map stuff here <-
//Now lets disable the InputMap
InputManager.Instance.PopInputMap(inputMap);
}It works and disables the InputMap, but If I try to make any use of this Pop feature elsewhere, like in my pause function, it doesnt seem to work (inputMap not in current context) I even did some extra coding to make it in context, but still wont work. Any help is greatly appreciated!About the author
Previously a PHP/MySQL Programmer/Web Developer of 10 years. In Aug 2010 I decided to change careers, and this is were I landed! I also parent 3 kids full time. TopNotched.com
#2
09/14/2010 (6:42 am)
In my project, I just checked to see if the game was paused before taking action in my InputMap. I didn't have to worry about my other InputMap doing things behind my back.
#3
09/14/2010 (11:46 pm)
Thanks John, I will give that a try.
#4
In your "Private, protected, internal fields" section (basically anywhere in your class), you need to define inputMap as the InputMap type:
Now you can push or pop anywhere in the code!
For more information, check out my other thread where I learned how to Regain Player Control after Pop/Push. Also Cosmic Logic posted code on how to Use a Game State to control the InputMap!
Cheers!
09/28/2010 (7:37 pm)
If your brand new to C# like I was, you probably are looking for the solution, so here it is! Ended up being a very basic C# "common sense" solution.In your "Private, protected, internal fields" section (basically anywhere in your class), you need to define inputMap as the InputMap type:
InputMap inputMap;
Now you can push or pop anywhere in the code!
For more information, check out my other thread where I learned how to Regain Player Control after Pop/Push. Also Cosmic Logic posted code on how to Use a Game State to control the InputMap!
Cheers!
Torque 3D Owner Aaron Scovel