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 13

    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 14

    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 15

    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?

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.