Forum rules - please read before posting.

Highlight in real time?

Hi there,

It seems that the Highlight component doesn't update the material brightness in case you're in a conversation (I use Dialogue System).

That is, I can't use HighlightOn, Off, or Pulse functions in that state. That also makes some hotspots remain bright just after I click on them to initiate a conversation, which isn't pretty.

For Dialogue System, I have the bridge component configured like this...:

...but selecting "Never" in "Use Dialog State" doesn't make a difference.

So, I'm guessing this is the way the script is written, to not support a real time timer (?).

Would it be possible to modify it so it does? Or am I missing something?

Comments

  • Is this to say your game is paused during this time?

    The Highlight script uses Time.deltaTime to measure progress. If you replace its usage of Time.deltaTime with Time.unscaledDeltaTime, does it give you the behaviour you're looking for?

  • Hi Chris, thanks for replying.

    I come back to you with some research done...

    Short version:

    Turns out StateHandler.cs Update() is NOT calling _Update() in Highlight.cs, because player interactions are off.

    Long version:

    If I select "Never" in the AC Bridge component, the AC Status is "Normal" during DS conversations. If I select "Always", AC Status is "DialogOptions".

    In both cases, Time Scale is 1 all the time, outside and inside DS conversations. At least from what I can see if I run a Get Time Scale to a counter, every frame.

    Regardless, when I call the Pulse() method of a Highlight component, it doesn't do anything (visually). It only starts doing so AFTER the conversation is over.

    It seems that the Pulse() section is indeed run to change the Highlight state to Pulse, but the _Update() function isn't run afterwards.

    Then I finally realized this is a custom Update() function (for performance reasons?), so it's supposed to be called from another place, which turns out is StateHandler.cs.

    Sorry, I'm not a pro coder and only learn what I need, as I need it, so I wasn't even familiar with custom Update() functions. :p

    Anyway, removing that leading underscore "solves" my problem. Update() is called every frame, checks for a non "None" highlight state and does its updating, so now it works inside conversations, regardless of StateHandler "blessings".

    However... doing this doesn't feel right.

    Now, what StateHandler checks is if interactionIsOff is false, so it calls _Update() for every Highlight component. That bool, in turn, is got from CanInteract (), which I couldn't go to the implementation in VisualStudio (don't know why).

    At any rate, I can imagine the highlight components not being updated when interaction isn't possible is a design decision you took. That's fair enough, and it doesn't sounds illogical especially when you disable interactions in a civilized manner, I guess. But I'm everything but civilized. :D

    So, I'll just remove that "if" in StateHandler and let it run at all times.

    In fact, I can imagine this is also the reason why hotspots remain bright after clicking, sometimes. And the labels also. Need to find where those are updated.

    Thank you for making me learn something new!

  • edited May 2023

    Edit: running _Update() in Highlight every frame wasn't enough for the highlighting effect being turned off after clicking a hotspot, and its associated DS conversation starting (with the cursor still hovering the hotspot).

    This is something that's being happening since ever for me, and couldn't find a fix. Now I thought Highlights being updated every frame would solve the issue, but it didn't.

    The only thing that has solved it has been adding this snippet of code in PlayerInteraction.cs:

    It seems to work, but I don't know if this will return to bite me in the rear.

    What do you think?

  • If you're disabling the Interaction system such that it doesn't update naturally, you can run the code you need outside of it - there shouldn't be a need to edit AC's scripts directly.

    The code you've added ultimately just disables the active Hotspot if you're in the "DialogOptions" game state. You can do that with a custom script that hooks into the OnEnterGameState custom event:

    using UnityEngine;
    using AC;
    
    public class HotspotDeselecter : MonoBehaviour
    {
    
        void OnEnable () { EventManager.OnEnterGameState += EnterGameState; }
        void OnDisable () { EventManager.OnEnterGameState -= EnterGameState; }
    
        void EnterGameState (GameState _gameState)
        {
            if (_gameState == GameState.DialogOptions && KickStarter.playerInteraction.GetActiveHotspot ()) 
                KickStarter.playerInteraction.GetActiveHotspot ().Deselect ();
        }
    
    }
    
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.