Forum rules - please read before posting.

Hold input to flash Hotspots

Hi,

I'm trying to use this script to get hotspots the flash on hold - https://adventure-creator.fandom.com/wiki/Hold_input_to_flash_Hotspots

I think I set everything up as instructed, but I'm getting this error - Assets\scripts\HoldToFlash.cs(125,59): error CS1061: 'HashSet' does not contain a definition for 'ToArray' and no accessible extension method 'ToArray' accepting a first argument of type 'HashSet' could be found (are you missing a using directive or an assembly reference?)

I have no idea what I'm doing, so this means nothing to me. Any help would be greatly appreciated...

Thanks

Comments

  • Thanks for the alert - it was made for an older AC release.

    I've updated the script to be compatible with the current version - give it a try now.

  • Thanks Chris,

    No more error. However, the hotspot icons now appear on pressing the input, but don't disappear on release...

    I'm using Unity 2020.3.22 and AC 1.73.1

  • Recreated, thanks for the bug report.

    To fix, open up AC's Highlight script and find the CancelFlash function around line 259:

    public void CancelFlash ()
    {
        if (direction >= 0 && highlightState == HighlightState.Flash)
        {
            direction = 0;
            currentTimer = -1f;
        }
    }
    

    Replace it with:

    public void CancelFlash ()
    {
        if (direction >= 0 && highlightState == HighlightState.Flash)
        {
            direction = -1;
            currentTimer = 0f;
        }
    }
    
  • Fantastic! That did the trick, thanks Chris!

  • Hi Chris! Heads up (and apologies) -- I just changed the code of the script at https://adventure-creator.fandom.com/wiki/Hold_input_to_flash_Hotspots, because it was setting isInGameplay to be false when it should be true.
    isInGameplay = (gameState != GameState.Normal)
    changed to
    isInGameplay = (gameState == GameState.Normal)

    I just wanted to comment on it, but I couldn't figure out how to add a comment, and the page was editable, so I made the change with an explanation (though I'm not sure where the explanation is visible, if anywhere). Sorry to just be changing wiki code, but it works for me after the change. I also added a couple of lines in OnEnable() to make sure isInGameplay gets initialized, because I wasn't getting any initial call to OnExitGameState() to set an initial value in isInGameplay.

  • edited February 2023

    Don't worry @RealHandy - the wiki is there to be edited by the community.

    Though, I'm not sure I'm following the change.

    The code you're changing is within the OnExitGameState event - where the passed "gameState" parameter you're exiting, so if it's equal to Gameplay, then that means you're no longer in gameplay.

    It looks like the initialisation is wrong because you've also added a call to this in OnEnable - but passing in the current gameState, which isn't currently being exited.

    What you could do is either hook into OnEnterGameState instead, or have the event hook ignore the parameter value completely, and just read the value of IsInGameplay directly, i.e:

    bool isInGameplay = KickStarter.stateHandler.IsInGameplay;
    
  • edited February 2023

    Oh, okay -- I didn't realize that it was wide open for changing, I thought you were "moderating" or some similar word. :smile:

    Still, I don't want to mess up something that was working. I didn't realize that the value passed into OnExitGameState() is the prior state that is no longer active, but it still wasn't working before my change, but due to lack of initialization. So I messed up what's going on in OnExitGameState(). I'll put it back. The lack of initialization of isInGameplay is the only issue, and my choice to initialize it with OnExitGameState() was also bad, again due to the param there being the prior state. I'll fix it with a proper initialization (really, calling IsInGameplay() is the best to get that value) and change OnExitGameState() to also use IsInGameplay(). Apologies, and thanks for clarifying that!

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.