- Home /
Coordinating control between multiple input classes
Dear Community,
In my game I have different input classes.
one for dragging objects around with left mouse button
one for moving the camera with middle mouse button
one for highlighting objects with right mouse button
one for instantiating objects on different keypresses
a Menu canvas with different buttons for left mouse button
a button that highlights when hovering over it with the mouse.
Some of these input classes should only process input when others are not processing. For example I don‘t want to allow instantiation while dragging. Or not allow moving the camera while on the menu. Or just highlight the button when not dragging etc.
Unfortunately I am at a loss. How would I go about allowing and disallowing these input classes when necessary?
Kind regards.
If this is the wrong place to ask such a question I'm grateful for ideas where else to ask. Thank you.
Answer by Zaba200 · Sep 14, 2020 at 07:26 AM
i would recommend an outside array with all the inputs saved as scriptable objects, and all of them to have a list of things that thay can allow instantaniusly with others and what they don't allow, and everytime you try to call an Input you search trought the array in search of with of them is active and if they allow the other input method to be active at the same time, and don't forget to activate and deactivate all the input methods in the array at the right time. This is how i would go about doing it, but i am sure there is an easier way of doing this.
Wow that's one idea. Thanks for your input :-)
It feels a little complicated to me. But at least it can work.
You don't think there is a way using an event system in some way? Setting some flags once one system activates?
Your answer
Follow this Question
Related Questions
How to get GameObject that is clicked by a mouse? 2 Answers
Projection to mouse position in isometric game 1 Answer
Input: Missing mouse button events 2 Answers
How to detect number of mouse/trackpad buttons? 0 Answers
Input.GetKeyDown, Input.GetKeyUp, and mouse wheel do not work while playing in the editor. 0 Answers