Forum rules - please read before posting.

Doubleclick hotspot

edited November 2022 in Technical Q&A

Hi Chris!

I need to execute a custom action on a hotspot when double click it - a door. I searched the forum about double clicking and have not found an answer.

You suggested in 2018 that the double click could be detected with this code running in update:

    if (AC.KickStarter.playerInput.GetMouseState() == MouseState.DoubleClick)
            {
                // Double-clicked
                if (AC.KickStarter.playerInteraction.GetHotspotMovingTo() == hotspot)
                {
                    // Already moving to the stairs hotspot
                    AC.KickStarter.playerInteraction.StopMovingToHotspot();
                    doubleClickAction.Interact(index, false);
                }
            }

But this does'nt work anymore and only detects when double clicking on the ground. The click seems to get consumed by the hotspot.

How could I detect the double click on a hotspot and trigger a custom action?

Thanks! Best!
Alex

Comments

  • Can you point a link to the page that was from, and what's the exact behaviour you're looking for? Should the Hotspot's regular interaction still run when single-clicking, or should a Hotspot only be interacte with upon double-clicking?

  • edited November 2022

    Sure. Here: https://adventurecreator.org/forum/discussion/3229/double-click-hotspot-action
    (At the bottom)

    And here: https://adventurecreator.org/forum/discussion/7132/custom-script-to-detect-double-click-only-when-a-hotspot-is-active

    When I double click on a door I want to leave a room instantly without moving the character to the marker position of the door.
    Triggers Interaction Instantly places the player instantly to the marker - I don't like that . What I would want to achieve with a custom action is that the player walks towards the marker during a fadeout and fast scene change.

  • This should be possible without the reliance on a custom script. Can you share shots of your Hotspot Inspector and Settings Manager?

  • edited November 2022

    https://dropbox.com/s/2bg5kr94frh0qq7/Hotspots.png

    I have a default behaviour on that door, which gets triggered when clicking on it once: The character walks to the door, walks behind it and the fadeout is triggered.

  • What is your AC version? An option to prevent the Player from snapping at the Marker should be available underneath the "Face after moving?" option.

    If you're using the latest, I'll need to see your full (uncropped) Settings Manager.

  • I don't have that option.

    I am on 1.75.4. - at which version is it available?
    My Settingsmanager: https://dropbox.com/s/suwe9rqim1w7joi/Settingsmanager.png?dl=0

  • It was introduced in v1.75.6.

  • edited December 2022

    Thanks. Before I update it - which is always a bit of a hassle because I hacked some custom functionality in AC - let me ask: What is the exact behaviour introduced?

    When it is only that the Use-ActionList is triggered without moving the character on the WalkToMarker spot then it wouldn't help me much. I need to trigger a custom ActionList or check the current state (doubleclicked or not) in the use-ActionList itself to be able to execute some custom behaviour.

  • The option prevents the Player from snapping to the WalkToMarker upon double-clicking the Hotspot.

    If you want to run custom behaviour when double-clicking a Hotspot, you can hook into the OnDoubleClickHotspot custom event:

    private void OnEnable () { EventManager.OnDoubleClickHotspot += OnDoubleClickHotspot; }
    private void OnDisable () { EventManager.OnDoubleClickHotspot -= OnDoubleClickHotspot; }
    
    private void OnDoubleClickHotspot (Hotspot hotspot, AC.Button button)
    {
        // Double-click on hotspot
    }
    

    Import into a backup/duplicate project if you're unsure, but I'd recommend relying on custom events wherever possible to avoid having to hack AC directly.

  • Oh thank you! This is exactly what I needed. I often forget to search through the scripting guide.

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.