Forum rules - please read before posting.

Hotspot Tap & choose interaction: double tap on the action icon to make the player run instd/o walk

Hi there!

I'm looking for a quick & dirty way to create such behaviour.

I already have the "double tap to run" set in the Settings.

I believe it also triggers sometimes when double tapping on the interaction, but I believe it has some inconsistent behaviour.

How did you manage to solve this?

Could you please help me or point me in the right direction (snippets are welcome)?

Thank you.

Comments

  • Double-tap to run only deals with general movement around the scene - not menu behaviour.

    It's not so trivial because the Interaction element requires a single-click, and the Menu it's within turns off once the Hotspot is interacted with.

    However, you could feasibly hook into the OnHotspotInteract custom event, which will trigger at this moment, and then run a co-routine to check for a second tap/click - and update the player's movement if so:

    public float maxDelay = 0.4f;
    
    private void OnEnable ()
    {
        EventManager.OnHotspotInteract += OnHotspotInteract;
    }
    
    private void OnDisable ()
    {
        EventManager.OnHotspotInteract -= OnHotspotInteract;
    }
    
    private void OnHotspotInteract (Hotspot hotspot, AC.Button button)
    {
        StartCoroutine (CheckForDoubleClick (hotspot));
    }
    
    private IEnumerator CheckForDoubleClick (Hotspot hotspot)
    {
        PlayerMenus.GetMenuWithName ("Interaction").isLocked = true;
    
        yield return new WaitForEndOfFrame ();
    
        float timer = maxDelay;
        while (timer > 0f && KickStarter.playerInteraction.GetHotspotMovingTo () == hotspot)
        {
            if (KickStarter.playerInput.LastClickWasDouble ())
            {
                Debug.Log ("Double-clicked!");
                KickStarter.playerInput.ResetMouseClick ();
                KickStarter.player.isRunning = true;
                timer = 0f;
            }
            yield return new WaitForEndOfFrame ();
            timer -= Time.deltaTime;
        }
    
        PlayerMenus.GetMenuWithName ("Interaction").isLocked = false;
    }
    
  • Thanks Chris!
    That's a clever solution I could have never come up with, I'm still far from mastering AC.

    So it's basically removing any other chance of interaction for the split of a second, checking if last click was double, regardless of anything that could be under the finger in that moment (I hope it can't trigger any other hotspot/interaction in the meanwhile!), so that there's no need to show the interaction icons more time than needed (which would have been much more complicated, also because I set a fadeout/pan on interaction).

    From an usability point of view I'm also considering to just check the distance/time needed to reach the hotspot. If it would take more than a second to traverse the path, it switches to running unless the interaction gets cancelled or the destination is reached.

    I guess there are events for cancelled interaction and reached hotspot as well, I will try to explore all of them via the code autocomplete feature.

  • All events are listed in the Manual - see the "Custom events" chapter.

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.