Forum rules - please read before posting.

Direct Navigation Issue

I'm trying to integrate gamepad control within my project.

I'm using the script below, attached to a gameobject in the scene:

https://adventure-creator.fandom.com/wiki/Switching_input_method_dynamically

Here's my current setup:


(I've tried it with Directly navigate when paused unchecked too)

When the pause menu appear the mouse cursor stays on screen and the first item isn't selected as I believe it should be.

I tried to make sure the 'auto select first visible element' worked at all by changing to Keyboard or Controller but it still didn't select it.

Basically it doesn't seem to be reacting to the script at all.

Do you have any idea why this isn't working?

I'm using AC 1.85.4 and Unity 6.2.

Comments

  • Putting aside the behaviour of Menus for the moment, is the "Input method" field changing dynamically?

    The script should cause it to switch to "Keyboard Or Controller" when the JoystickButton input is pressed. Note that you can define a separate button in the Alt Postive Button field, as well as define other inputs of the same name, to have it react to more inputs.

  • Hi Chris, yes it is.

    This morning I set it all up again and it seemed to suddenly begin to partially work. I can now switch between the two control methods, but if a menu is active when the gamepad is in use and the first menu element is selected, moving the mouse after that doesn't de-active the selected element so it visually looks wrong if you know what I mean.

    Is there any way I can remedy this?

  • edited December 2025

    The script only kicks in when a button is pressed - just moving the mouse won't have an effect.

    The script is kept intentionally simple, however, so that it can be easily edited to suit the individual project's needs. Try adding this to the end of the Update function:

    else if (Input.mousePositionDelta.sqrMagnitude != 0f)
    {
        SetInputMethod (InputMethod.MouseAndKeyboard);
    }
    

    If you want to de-select the active Unity UI element when switching to Mouse And Keyboard, add this to the "Set any mouse/keyboard-specific settings here" section:

    KickStarter.playerMenus.SelectUIElement(null);
    
  • Thanks Chris, that seems to have fixed up the issue.

    How do I make it so the mouse cursor can be controlled with a gamepad when outside of the non-directly controlled menus?

  • Make sure that you use Software rendering in the Cursor Manager, and you can then map the gamepad's axes to the CursorHorizontal and CursorVertical axes to control it.

  • edited December 2025

    That's what I've already done but it doesn't do anything:

    Even with it set as Keyboard & Mouse, the controller won't move the mouse cursor, despite it being set to a software cursor. Buttons all work as they should, it just won't move the cursor at all.

  • The inputs look correct.

    In a separate project if need be, use the New Game Wizard to create a new 2D Point and Click game with Keyboard Or Controller input. With the CursorHorizontal/Vertical inputs above, you should have control over the game's cursor (not the mouse, to be clear) with the gamepad upon running the sample scene.

  • Hi Chris

    I just tried that but no luck unfortunately.

    I started a brand new project and used the New Game Wizard to create a 2D point & click with Keyboard or Controller input but the gamepad still doesn't work at all. Neither does the mouse, actually. It plays the little intro where he walks in and talks but that's it - no interaction at all is possible.

    CursorHorizontal and CursorVertical weren't in the Input Manager, but even adding them doesn't make a difference. I'm baffled.

  • edited December 2025

    Ah, it DOES work when using the New Input System. Using the old one doesn't work for some reason.

    Now, I don't mind using the New Input System in my project, but my question is how have you managed to get it to switch to directly-controlled when the menus appear, as you don't seem to have used a script that switches input...

    Also, there aren't any CursorHorizonal or CursorVertical defined in the Action asset of the Input Controller?

    My game is basically one huge Unity UI.

    It's essentially a computer screen that the player can interact with, clicking on this and that, etc. This is where I'd like the player to be able to use their mouse or a gamepad for a cursor. But when certain menus (like pause) appear, I'd like it switch to directly-controlled and have the cursor disappear (if using the gamepad).

    Is it possible for me to do this?

  • The input-switching is automated via the Auto Sync Input Method option on the Event System prefab that AC's Input System integration template assigns in the Menu Manager.

    This integration uses its own Actions asset - Controls - that it places in the InputSystem subfolder of your game. CursorHorizontal and CursorVertical are defined in the UI mapping.

    If your game's core is already well-established by this point, it may be best to stick with Input Manager, rather than Input System however. The reason the new project had issues - if you were using Unity 6.2 or later - is because Unity defaults to the use of Input System. You can enable the use of Input Manager by going to the Player section of the Project settings and setting the Input handling field to Input Manager.

  • I'll stick with the old Input Manager in this case. The only issue I have is that the cursor still refuses to be moved around with the gamepad, as described above.

  • Follow the steps above of testing in a fresh project, but this time keep the Input Handling as Input Manager.

  • edited December 2025

    Ah, it seems to be working in the 2D test scene! I had to alter the sensitivity under the CursorVertical/Horizontal settings but yes, it seems to be working.

    It's not, however, working in my actual game, despite having all the same settings. I thought it was because my game is a huge UI so it's trying to auto select the first element, which I don't want it to do, but upon creating a new blank scene the cursor still won't move with the gamepad. Menus can be directly navigated though.

  • edited December 2025

    I've now manged to get it working!

    The only issue I have now is the Input Switcher script automatically trying to switch it to Direct Navigation when it's on the 'computer screen' section of the scene as seen below (it's essentially a huge UI):

    Whenever it shows this screen I need it to switch to a cursor controlled by the gamepad/mouse despite if it detects the controller being used. It's the only scene in the entire game where a cursor for the gamepad is required, everything else would be directly navigated by the gamepad (if it was being used, otherwise it'd switch to the standard mouse cursor for keyboard and mouse play)

    Also, is it possible to have that script detect when a gamepad's axis is moved rather than a button?

  • Best to create a duplicate of the wiki script and use this variant just for this scene, then.

    The "switch" block at the bottom is what enforces direct-navigation. To have it use cursor-navigation, replace it with:

    KickStarter.menuManager.keyboardControlWhenCutscene =   KickStarter.menuManager.keyboardControlWhenPaused =     KickStarter.menuManager.keyboardControlWhenDialogOptions = true;
    KickStarter.playerMenus.FindFirstSelectedElement ();
    

    To detect an axis move instead of the button, replace:

    if (Input.GetButtonDown (enableJoystickInputName))
    

    with:

    if (new Vector2(Input.GetAxisRaw("CursorHorizontal"), Input.GetAxisRaw("CursorVertical")).sqrMagnitude > 0.1f)
    

    If you've CursorHorizontal / Vertical are defined twice (one set for gamepad, another for mouse), then duplicate another just for gamepad, rename it, and use that in the code above.

  • edited December 2025

    Hi Chris, thanks for that, but I'm a little confused.

    The "switch" block at the bottom is what enforces direct-navigation. To have it use cursor-navigation, replace it with:

    KickStarter.menuManager.keyboardControlWhenCutscene = KickStarter.menuManager.keyboardControlWhenPaused = KickStarter.menuManager.keyboardControlWhenDialogOptions = true;
    KickStarter.playerMenus.FindFirstSelectedElement ();

    That's what was already in the script? Should it have said something else? Or do you mean so it looks like this:

    private void SetInputMethod(InputMethod inputMethod, bool force = false)
    {
        if (KickStarter.settingsManager.inputMethod != inputMethod || force)
        {
            KickStarter.settingsManager.inputMethod = inputMethod;
    
            KickStarter.menuManager.keyboardControlWhenCutscene = KickStarter.menuManager.keyboardControlWhenPaused = KickStarter.menuManager.keyboardControlWhenDialogOptions = true;
            KickStarter.playerMenus.FindFirstSelectedElement();
            // Set any keyboard/controller-specific settings here
        }
    }
    
  • I may have copied the wrong block. Try this instead:

    private void SetInputMethod(InputMethod inputMethod, bool force = false)
    {
        if (KickStarter.settingsManager.inputMethod != inputMethod || force)
        {
            KickStarter.settingsManager.inputMethod = inputMethod;
    
            KickStarter.menuManager.keyboardControlWhenCutscene = KickStarter.menuManager.keyboardControlWhenPaused = KickStarter.menuManager.keyboardControlWhenDialogOptions = false;
        }
    }
    
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.