Forum rules - please read before posting.

Detect double click for certain hotspots

I'm working on a specific mini puzzle (2D) within my project. For this puzzle, I'd like to show different sequences of ActionList based on whether the player does a single click or a double click. (It's worth noting that this double click mechanism is just for this particular puzzle, not a recurring game mechanic.) I'm utilizing Global Variables, and my ActionLists are saved as assets.

I came across the following line of script and tried incorporating it with the Object: Send Message action:

if (AC.KickStarter.playerInput.GetMouseState() == MouseState.DoubleClick)

However, I'm having trouble figuring out how to implement this correctly. Any guidance or ideas would be greatly appreciated. Thank you so much.

Comments

  • GetMouseState is used to initiate the Hotspot interaction - but by the time the Interaction is running, and the Action is run, it's no longer valid.

    However, the PlayerInput script has a dedicated LastClickWasDouble function that can be used to check if Player just double-clicked.

    This can be incorporated into a custom Action to re-route your list accordingly:

    using UnityEngine;
    
    namespace AC
    {
    
        [System.Serializable]
        public class ActionCheckDoubleClick : ActionCheck
        {
    
            public override ActionCategory Category { get { return ActionCategory.Input; }}
            public override string Title { get { return "Check double-click"; }}
    
            public override bool CheckCondition ()
            {
                return KickStarter.playerInput.LastClickWasDouble ();
            }
    
        }
    
    }
    
  • I can't thank you enough, Chris! It works perfectly! I really appreciate your time.

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.