Forum rules - please read before posting.

Custom double-click on hotspot not triggering

Hello,
I am trying yo apply custom script on double-click on hotspot and I found this discussion
I tried to do the same, but the AC.KickStarter.playerInput.GetMouseState() never goes to MouseState.DoubleClick when it's on a hotspot. It's ok wherever else though. When trying to debug, it seems that the MouseState is "HeldDown" and "LetGo" when double-clicking on hotspot. Is there a supplementary setting needed to apply that ?
I am using Mouse and Keybord as Input method.

Thanks in advance !

Comments

  • What is it you're actually trying to do? And what is the result of single-clicking a Hotspot? To have the Player move towards it (in a cutscene or not?) before running the default interaction?

    Best to see the Hotspot's Inspector as well as your Settings Manager.

    You could try detecting for a second click once the first has been used to interact with the Hotspot, i.e.:

    using UnityEngine;
    using AC;
    
    public class DoubleClickTest : MonoBehaviour
    {
    
        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)
        {
            yield return new WaitForEndOfFrame ();
    
            float timer = maxDelay;
            while (timer > 0f && KickStarter.playerInteraction.GetHotspotMovingTo () == hotspot)
            {
                if (KickStarter.playerInput.LastClickWasDouble ())
                {
                    Debug.Log ("Double-clicked!");
                    timer = 0f;
                }
                yield return new WaitForEndOfFrame ();
                timer -= Time.deltaTime;
            }
        }
    }
    
  • edited May 2020

    Hi @ChrisIceBox , thank you for your quick reply.
    The single-clicking on hotspot works perfectly, it triggers the Use Interaction (or Examine interaction for right click, if enabled). I would like to trigger a slightly different Interaction when double-clicking and not just triggers action instantly. I tried this option, it works but does not really fit my needs, that's why I tried to do it by hand.

    I tried your code and it's just what I needed, thank you !

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.