Forum rules - please read before posting.

Resetting the cursor after clicking the same interaction element

Hello, I'm looking for some help with the 'interaction then hotspot' method and menu elements.

It's working mostly as intended; I have a menu with four interaction elements set up, and have checked the setting to reset the cursor after an interaction with a hotspot. The cursor also changes when clicking from one interaction to another. The only other thing I'd like is when a player clicks on the same interaction, it resets the cursor back to default. Is there a setting that can enable this, or does it require a more manual set up?

Thanks fore your help!

Comments

  • Ah, so each icon acts like a toggle?

    This should be achievable through custom scripting, though I should also mention that similar results could likely be gotten by using Inventory items instead of Interaction icons - since clicking Items twice will select/de-select them.

    The scripting route would likely involve hooking into AC's OnMenuElementClick event, checking if you'd clicked the icon, and then resetting the cursor if there was no change. Try something along these lines:

    using UnityEngine;
    using AC;
    
    public class ToggleCursor : MonoBehaviour
    {
    
        int cursorID;
    
        void OnEnable() => EventManager.OnMenuElementClick += OnMenuElementClick;
        void OnDisable() => EventManager.OnMenuElementClick -= OnMenuElementClick;
    
        void Update()
        {
            cursorID = KickStarter.playerCursor.GetSelectedCursorID();
        }
    
        void OnMenuElementClick(Menu menu, MenuElement element, int slot, int buttonPressed)
        {
            if (element.title == "Use")
            {
                if (cursorID == KickStarter.playerCursor.GetSelectedCursorID())
                {
                    KickStarter.playerCursor.ResetSelectedCursor();
                }
            }
        }
    
    }
    
  • Yeah like a toggle, exactly. I've had a look at both methods, and for me this script worked best, thank you so much!

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.