Forum rules - please read before posting.

Controller/Mouse Enable/Disable

Hi,

I’ve tried setting this up several times, but I’ve hit a wall and could use some guidance.

What I’m trying to do is show a prompt at game start that lets the player choose between two control schemes: Controller (Direct method + controller or keyboard) and Keyboard and Mouse (Point-and-click + mouse and keyboard).

Selecting Controller should set a variable to true, which enables alternate UI prompts; otherwise, the standard UI is shown.

I tried adapting the script from this thread:
https://adventurecreator.org/forum/discussion/11065/auto-detecting-mouse-and-or-controller-input

However, I’m running into issues with UI focus and refreshing after switching methods—UI elements fail to refocus on the visible elements, and when Direct control is active, the system mouse cursor can lock in place and randomly select UI elements.

I don’t need dynamic input switching based on player input. My setup is simple: each input has a Positive (keyboard/mouse) and an Alt Positive (controller), and this part works reliably.

Ideally, I’d just toggle a variable via an ActionList and switch the Movement and Input Methods, but Input Method doesn’t appear to be accessible from ActionLists. I’m considering creating a custom Adventure Creator action to control the Input Method directly. - But I'm unsure if that's the best way to approach this.

Any advice on the cleanest way to approach this would be greatly appreciated. I originally tried dynamic switching, but it introduced too many edge cases, so I’m aiming for a straightforward variable-based solution instead.

Thanks again for the help.

Comments

  • What are your AC/Unity versions?

    I'm not clear if the issue is down to the inputs themslves, or the changes that need to be made at runtime based on the chosen input method.

    Before incorporating the ability to switch method at runtime (even if it's just the once), I'd recommend playing the game with Direct / Keyboard+Controller enforced, to work out what other settings need to be changed, as well as determine if the issue is present when all settings are fixed as opposed to set at runtime.

  • Hi Chris, thanks for replying so quickly. I'm using 6000.0.31f1 Unity and 1.85.3 for AC. How do I do that (playing the game with Direct / Keyboard+Controller enforced). Thank you again.

  • I just meant to set the values manually in the Settings Manager, play the game without anything dynamic, and working out what values everything should be set to before attempting to set them through script.

  • edited February 20

    Ah, that. Yes, I've done that. The problem seems to be with the system/cursor when you play in direct/controller. For exmaple, in the title screen, the menu is set up to work with direct method, but if I click the mouse once it defocuses everything and I can't get that back. The cursor also selects random menu elements and highlights them.

    I've set all menus already to select first visibile and as a help to the UI refocus issue I usually add Select Menu Element First Visible on Back Buttons when I exit menus.

    Menu elements also seem to defocus based on the "Pause Game" option in menus. For example, if I open a Menu that has the option enabled and then I go back to the initial menu (that has the option disabled), so I try to have the menu option consistent and have it either turned on or turned off for all.

  • Are you locking the cursor when under direct control, and are you letting AC spawn its own Event System?

    ACs Event System includes the Optional Mouse Input Module, which - for Input Manager - should prevent mouse input when the current game state allows for direct Menu control.

    As well as the "Directly navigate" options at the top of the Menu Manager, this also includes the "during gameplay" option from the Engine: Manage systems Action. Enabling all ought to prevent mouse input interacting with the UI at all times.

    InteractionA / B inputs, however, will still be read if they're mapped to the mouse. Are these, or any others, mapped to mouse buttons in the Input Manager?

  • Hi Chris,

    Thanks again for all your help.

    Here is a recording of my settings. I tried to incorporate every element you mentioned in your reply.

    https://drive.google.com/file/d/1a10ZKzs__d4s5_8zJvOofNhOGilxO3LQ/view?usp=sharing

    Sorry about the system cursor. I tried to make it visible with the recording software, but it does not seem to be working. Whenever you see the menu elements from the prompt get deselected, that is a mouse click within the game window at runtime.

    I have also included an image of Input A and B. Yes, I use the Left and Right Mouse buttons as well as A and B on the controller.

    https://drive.google.com/file/d/1W7ajIwCvUB7aDpcZwuMVIQ7hT8-ukP/view?usp=sharing

  • The Menu uses Unity UI, I take it.

    It is not clear from your video if the Event System is being generated by the Menu Manager. What is its full Inspector?

    The image link gives me a "file does not exist" page.

  • edited February 22

    https://drive.google.com/file/d/1H0a4bX-xz9fKPTKvmgTFlsgu2uYQS2x6/view?usp=sharing < sorry about that, don't know what happened there.

    Here's a screenshot of the Inspector for the Event System - https://drive.google.com/file/d/1abRIrSSrt_a6Tq-ReaLgpiMJL5RnhmNY/view?usp=sharing

    Yes, All my Menus sources are Unity UI Prefabs or Unity UI in Scenes.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.