Forum rules - please read before posting.

System/Game Cursors Incompatible with Multiple Interactions in First Person?

I'm trying to make a simple prototype with a first-person view in AC. It seems like the way the system works, it's incompatible with multiple Interactions in Hotspots. It seems like my only options are:

  1. The System and Game cursors are locked to center, which prevents multiple Interactions from being hovered on (I assume because the Game cursor is between where the Interaction icons appear?). Single-use Interactions work, but that's not what I want to do.
  2. The System cursor is not locked, but the game one is. If Interactions are set to appear on Mouse Over, they will only appear if the Game cursor (which is locked to the center) is over it, and the System/Game cursors are out of sync. This is really unintuitive.
  3. Neither cursor is locked. This breaks the AC First-Person camera, because for you to turn the camera with the mouse, the Game cursor appears to need to be locked to center.

Am I missing something obvious? What I want to do is select between multiple Interactions if hovering on a Hotspot (the Interactions would be positioned at the Hotspot, not at the cursor), and turn the First Person camera by moving the mouse. It seems like it should be possible, so I'm sure this is just me not checking the right boxes in the settings (as usual). Any help would be greatly appreciated ! :smiley:

Comments

  • With your intended behaviour, how is it that the player chooses between the available interactions?

    You're not limited to using the cursor: if you set your Select Interactions by field to Cycling Menu And Clicking Hotspot, you can use e.g. the mouse scrollwheel, mapped to the CycleInteractions input, to cycle through the available options. See the Manual's "Choose Hotspot And Interaction" chapter for more on this.

    Regarding the cursor: having the System and Game cursor be separate is optional. If your Cursor Manager's Cursor rendering mode is set to Software, then they'll be separate - though this should only appear so in Play mode depending on the options above. In builds, the system cursor should be hidden.

    However, you can instead set this to Hardware, which causes AC to rely on the System cursor itself - no separation needed.

    If you want the cursor to be moveable only while the Interaction menu is on, you can run Engine: Manage systems Actions as part of the Menu's ActionList when turn on/off properties, to temporarily disable free-aiming, and unlock the cursor.

  • Thanks for the quick and thorough reply! :smile:

    Ideally, I'd like to simply click the Interaction icons when the mouse is over them to run the interaction. The reason for this is that I want to have many different kinds of interactions within my game, and it's important that the player can see their options all at once — think "skill checks", like "Requires [9] Strength to Force Open Door", "Requires [4] Intelligence to Pick the Lock", etc. but displayed as icons instead of text.

    It seems so close to working — the Interaction buttons appear, positioned over the hotspot, and I can easily position the cursor over them — but they are not clickable. :'(

  • I need to know details of your setup. Can you share images of your Settings Manager and Interaction menu properties?

  • Sure thing! :)

    Thanks for taking a look!

  • edited April 7

    It looks like this is down to the Unity - by default - not allowing UI interactions with a locked cursor.

    I may be able to add a way get around this - I will look into it as part of the next update. In the meantime, however, relying on Adventure Creator for the Interaction menu's Source should have it work.

  • Thanks so much! :smiley:
    I tried switching to AC to be the Source for the Interaction menu, and now the Interaction Icons are highlighted when the cursor is over them — which is promising. However, when I click on it, the interaction isn't running. Hope it's just me checking the wrong thing in the settings again :')

  • Does it work if you press a keyboard input with the label "InteractionA"?

    A potential fix for the issue with Unity UI: open up AC's OptionalMouseInputModule script and copy/paste this at the top of its GetMousePointerEventData function:

    if (KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard)
    {
        if (Cursor.lockState == CursorLockMode.Locked)
        {
            var lockState = Cursor.lockState;
            Cursor.lockState = CursorLockMode.Confined;
            var mouseState = base.GetMousePointerEventData (id);
            Cursor.lockState = lockState;
            return mouseState;
        }
    
        return base.GetMousePointerEventData (id);
    }
    
  • Input method didn't work (though perhaps I set it up incorrectly? — I just used the same set-up as the Crouch Input with InteractionA as the name and "f" as the button).

    Thanks so much for the code! It runs the Interactions when the buttons are clicked (yay), but now the buttons aren't highlighted when the mouse hovers over them. :') I'm also getting a glitch where the Interaction buttons disappear when the mouse was hovered over them, which seems to pop up after I test the game more than once :s

  • edited April 9

    now the buttons aren't highlighted when the mouse hovers over them.

    Add this function to OptionalMouseInputModule:

    void RaycastMouse ()
    {
        PointerEventData mouseData = new PointerEventData (KickStarter.playerMenus.EventSystem);
        mouseData.Reset ();
    
        Vector2 pos = KickStarter.playerInput.GetMousePosition ();
    
        mouseData.position = pos;
        eventSystem.RaycastAll (mouseData, m_RaycastResultCache);
        RaycastResult raycast = FindFirstRaycast (m_RaycastResultCache);
        mouseData.pointerCurrentRaycast = raycast;
        m_RaycastResultCache.Clear ();
        KickStarter.playerMenus.EventSystem.SetSelectedGameObject (raycast.gameObject);
    }
    

    Then, replace:

    var mouseState = base.GetMousePointerEventData (id);
    

    with:

    var mouseState = base.GetMousePointerEventData (id);
    RaycastMouse ();
    

    I'm also getting a glitch where the Interaction buttons disappear when the mouse was hovered over them, which seems to pop up after I test the game more than once

    What is your AC version? This sounds related to an issue that should be fixed in the latest release.

  • My AC version was the latest version, but I was using an old version of the editor. I bit the bullet and just started over from scratch in Unity 6 — seems to be working now (with the help from the code you provided)! Thank you so much for your patience and help with 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.