Forum rules - please read before posting.

Show pending interaction whilst action/interaction is running during cutscene?

135

Comments

  • GetMovingTo will only be set for interactions specified in the Hotspot Inspector. As with the other related thread, I will look to see if unhandled use behaviour can be defined in the Hotspot. Please share your Settings Manager's full "Interaction settings".


  • Let me know if you need any other information, thanks!

  • After upgrading to 1.70, I'm getting this error: Assets\Verb1txtVerb2.cs(100,21): error CS1061: 'Hotspot' does not contain a definition for 'IsInventoryButton' and no accessible extension method 'IsInventoryButton' accepting a first argument of type 'Hotspot' could be found (are you missing a using directive or an assembly reference?)

    Here's the script that worked before the update:

    `using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using AC;

    public class Verb1txtVerb2 : MonoBehaviour
    {

    public Text textBox1;
    public Text textBox2;
    public GameObject bg;
    private bool textOnce;
    private bool textOnEvent;
    private string newLabel;
    private bool amInteraction;
    private bool amCutscene = true;
    Interaction myInteraction;
    private bool invInteraction;
    
    private Animator _animator;
    public float heightofclick;
    
    private void Start()
    {
        _animator = GetComponent<Animator>();
    }
    
    private void OnEnable()
    {
        EventManager.OnHotspotInteract += MyUse;
        EventManager.OnExitGameState += ExitGameState;
        EventManager.OnEnterGameState += EnterGameState;
        EventManager.OnBeginActionList += OnBeginActionList;
        EventManager.OnEndActionList += OnEndActionList;
        EventManager.OnInventoryInteract += OnInventoryInteract;
    }
    
    private void OnDisable()
    {
        EventManager.OnHotspotInteract -= MyUse;
        EventManager.OnExitGameState -= ExitGameState;
        EventManager.OnEnterGameState -= EnterGameState;
        EventManager.OnBeginActionList -= OnBeginActionList;
        EventManager.OnEndActionList -= OnEndActionList;
        EventManager.OnInventoryInteract -= OnInventoryInteract;
    
    }
    
    private void OnInventoryInteract(InvItem invItem, int iconID)
    {
        invInteraction = true;
        print("is inventory");
        int language = Options.GetLanguage();
        newLabel = KickStarter.cursorManager.GetLabelFromID(iconID, language) + " " + invItem.GetLabel(language);
    }
    
    private void OnEndActionList(ActionList actionList, ActionListAsset actionListAsset, bool isSkipping)
    {
        if (invInteraction == true)
        {
            invInteraction = false;
            print("inventory actionlist cancel");
    
        }
    }
    
    private void EnterGameState(GameState gamestate)
    {
        if (gamestate == GameState.Cutscene)
        {
            amCutscene = true;
        }
    }
    private void ExitGameState(GameState gamestate)
    {
        if (gamestate == GameState.Cutscene)
        {
            textOnEvent = false;
            amInteraction = false;
            amCutscene = false;
        }
    }
    private void OnBeginActionList(ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
    {
        if (actionList is Interaction)
        {
            amInteraction = true;
            myInteraction = actionList as Interaction;
        }
    
    }
    private void MyUse(Hotspot hotspot, AC.Button button)
    {
        textOnEvent = true;
        if (button != null)
        {
            int language = Options.GetLanguage();
            newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language);
        }
        if (hotspot.IsInventoryButton(button))
        {
            int language = Options.GetLanguage();
            newLabel = KickStarter.playerInteraction.GetLabelPrefix(hotspot, KickStarter.runtimeInventory.SelectedItem, language) + " " + hotspot.GetName(language);
        }
    }
    
    private void Update()
    {
        bool doHold = false;
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null
            )
        {
            if (textOnce == false)
            {
                textBox2.text = textBox1.text;
                textBox2.enabled = true;
                bg.SetActive(true);
                textOnce = true;
            }
    
        }
        else
        {
            textBox2.text = textBox1.text;
            textBox2.enabled = false;
            bg.SetActive(false);
            textOnce = false;
        }
        if (textOnEvent == true || invInteraction == true)
        {
            textBox1.text = newLabel;
        }
        if (KickStarter.playerInteraction.GetHotspotMovingTo() == null
            && amInteraction == false
            )
        {
            textOnEvent = false;
        }
    
        if (myInteraction != null)
        {
            if (!myInteraction.AreActionsRunning())
            {
                //textOnEvent = false;
                amInteraction = false;
                // Interaction is set, but no Actions are running
            }
        }
    
        //Highlight Script
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null
            || amInteraction == true
            //||  textOnEvent == true
                )
        {
            doHold = true;
        }
        _animator.SetBool("Hold", doHold);
    
        if (Input.GetMouseButtonDown(0) &&
            KickStarter.playerInteraction.GetActiveHotspot() == null &&
            Camera.main.ScreenToViewportPoint(Input.mousePosition).y >= heightofclick
            && amInteraction == false
            && amCutscene == false
            )
        {
            _animator.SetTrigger("Flash");
        }
    
    }
    

    }`

  • See the upgrade notes in the Changelog, specifically:

    The Hotspot script's IsInventoryButton function has been replaced with GetButtonInteractionType

    Replace:

    if (hotspot.IsInventoryButton(button))
    

    with:

    if (hotspot.GetButtonInteractionType (button) == HotspotInteractionType.Inventory)
    
  • It seems to work nicely, except if I interact with an inventory item, the text gets stuck as the action (Look at Newspaper, Use Newspaper, etc). The current script:

    `using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using AC;

    public class Verb1txtVerb2 : MonoBehaviour
    {

    public Text textBox1;
    public Text textBox2;
    public GameObject bg;
    private bool textOnce;
    private bool textOnEvent;
    private string newLabel;
    private bool amInteraction;
    private bool amCutscene = true;
    Interaction myInteraction;
    private bool invInteraction;
    
    private Animator _animator;
    public float heightofclick;
    
    private void Start()
    {
        _animator = GetComponent<Animator>();
    }
    
    private void OnEnable()
    {
        EventManager.OnHotspotInteract += MyUse;
        EventManager.OnExitGameState += ExitGameState;
        EventManager.OnEnterGameState += EnterGameState;
        EventManager.OnBeginActionList += OnBeginActionList;
        EventManager.OnEndActionList += OnEndActionList;
        EventManager.OnInventoryInteract += OnInventoryInteract;
    }
    
    private void OnDisable()
    {
        EventManager.OnHotspotInteract -= MyUse;
        EventManager.OnExitGameState -= ExitGameState;
        EventManager.OnEnterGameState -= EnterGameState;
        EventManager.OnBeginActionList -= OnBeginActionList;
        EventManager.OnEndActionList -= OnEndActionList;
        EventManager.OnInventoryInteract -= OnInventoryInteract;
    
    }
    
    private void OnInventoryInteract(InvItem invItem, int iconID)
    {
        invInteraction = true;
        print("is inventory");
        int language = Options.GetLanguage();
        newLabel = KickStarter.cursorManager.GetLabelFromID(iconID, language) + " " + invItem.GetLabel(language);
    }
    
    private void OnEndActionList(ActionList actionList, ActionListAsset actionListAsset, bool isSkipping)
    {
        if (invInteraction == true)
        {
            invInteraction = false;
            print("inventory actionlist cancel");
    
        }
    }
    
    private void EnterGameState(GameState gamestate)
    {
        if (gamestate == GameState.Cutscene)
        {
            amCutscene = true;
        }
    }
    private void ExitGameState(GameState gamestate)
    {
        if (gamestate == GameState.Cutscene)
        {
            textOnEvent = false;
            amInteraction = false;
            amCutscene = false;
        }
    }
    private void OnBeginActionList(ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
    {
        if (actionList is Interaction)
        {
            amInteraction = true;
            myInteraction = actionList as Interaction;
        }
    
    }
    private void MyUse(Hotspot hotspot, AC.Button button)
    {
        textOnEvent = true;
        if (button != null)
        {
            int language = Options.GetLanguage();
            newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language);
        }
        if (hotspot.GetButtonInteractionType(button) == HotspotInteractionType.Inventory)
        {
            int language = Options.GetLanguage();
            newLabel = KickStarter.playerInteraction.GetLabelPrefix(hotspot, KickStarter.runtimeInventory.SelectedItem, language) + " " + hotspot.GetName(language);
        }
    }
    
    private void Update()
    {
        bool doHold = false;
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null
            )
        {
            if (textOnce == false)
            {
                textBox2.text = textBox1.text;
                textBox2.enabled = true;
                bg.SetActive(true);
                textOnce = true;
            }
    
        }
        else
        {
            textBox2.text = textBox1.text;
            textBox2.enabled = false;
            bg.SetActive(false);
            textOnce = false;
        }
        if (textOnEvent == true || invInteraction == true)
        {
            textBox1.text = newLabel;
        }
        if (KickStarter.playerInteraction.GetHotspotMovingTo() == null
            && amInteraction == false
            )
        {
            textOnEvent = false;
        }
    
        if (myInteraction != null)
        {
            if (!myInteraction.AreActionsRunning())
            {
                //textOnEvent = false;
                amInteraction = false;
                // Interaction is set, but no Actions are running
            }
        }
    
        //Highlight Script
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null
            || amInteraction == true
            //||  textOnEvent == true
                )
        {
            doHold = true;
        }
        _animator.SetBool("Hold", doHold);
    
        if (Input.GetMouseButtonDown(0) &&
            KickStarter.playerInteraction.GetActiveHotspot() == null &&
            Camera.main.ScreenToViewportPoint(Input.mousePosition).y >= heightofclick
            && amInteraction == false
            && amCutscene == false
            )
        {
            _animator.SetTrigger("Flash");
        }
    
    }
    

    }`

  • "Gets stuck" as in it displays forever, or doesn't display?

    You'll need to elaborate much more about the actual vs expected behaviour here. Though, the check you're making in OnEndActionList should kick in correctly - you can make whatever adjustments you need to there.

    Ideally such a script wouldn't require an Update function - at least to change the state of UI components. You should be able to do most things purely from events. AC now has an "OnHotspotStopMovingTo" event, and will be getting an "OnHotspotReach" event in the next update - together I should hope that this would be enough to custom control "pending Hotspot label" behaviour without the need for an Update function.

  • Sorry, I should have elaborated more! The sentence doesn’t clear, as if the check has changed for when an inventory interaction has completed, and the text should return to non-held.
  • It doesn't clear when the interaction ActionList ends?

    Your "inventory actionlist cancel" debug message shows up, so you can make adjustments there if needed.

  • edited April 2020

    Here is an example of my issue: https://gfycat.com/safejoyousfirefly

    As you can see, when using an inventory item, it just stays forever as the interaction text, when it should return to normal after the use interaction is completed. This seems to be new with the recent update to AC.

    I'm also not sure why interactions just say the hotspot name now unless right-clicked (ie: default interaciton for hotspot is run).

    This is the code that changes the text to hold during the inventory interaction:

    private void OnInventoryInteract(InvItem invItem, int iconID) { invInteraction = true; print("is inventory"); int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(iconID, language) + " " + invItem.GetLabel(language); }

    When should this be finished so invInteraction can be returned to false? It used to work during:

    `private void OnEndActionList(ActionList actionList, ActionListAsset actionListAsset, bool isSkipping)
    {
    if (invInteraction == true)
    {
    invInteraction = false;
    print("inventory actionlist cancel");

        }
    }`
    

    But I'm not sure this is working anymore since "inventory actionlist cancel" doesn't actually display after running the use interaction on the inventory item.

  • What controls the text display, though? Your "textBox2.enabled" calls? That's only set to true when moving to a Hotspot. I would expect the same behaviour with older AC versions - what were you upgrading from, and what are you using now?

    It's a confusing script to debug, and it's not clear what each public field is assigned to.

  • edited April 2020

    This is how it is set-up:

    The bgbox is enabled and covers the txtVerbLine during hold, the text from txtVerbLine is copied into txtVerbLineCopy and the text component on txtVerbLineCopy is held there during the walk to the interaction. After the interaction, the bgbox is disabled and the txtVerbLineCopy text component is disabled. This isn#t happening anymore after an inventory interaction.

    It was from 1.69 to 1.70.

  • edited April 2020

    It was from 1.69 to 1.70.

    Can you be more specific? What were the sub-versions?

    After the interaction, the bgbox is disabled and the txtVerbLineCopy text component is disabled. This isn't happening anymore after an inventory interaction.

    So, you're saying "KickStarter.playerInteraction.GetHotspotMovingTo()" is not returning null when it should be? Use a print statement to confirm this in the Console.

    Either way, it seems like a convoluted way of doing things - you shouldn't need two Text fields and another panel to hide them.

    But I'm not sure this is working anymore since "inventory actionlist cancel" doesn't actually display after running the use interaction on the inventory item.

    It does for me. Place another print statement just inside your OnEndActionList event to confirm it's being run, but you should be checking if the ActionList being ended is equal to "myInteraction" so you can be sure that's what's being ended. Otherwise, any ActionList ending during that time will cause "invInteraction" to become false.

  • edited April 2020

    Sorry, it was 1.66.4, this version says 1.67.0 in the status, but I believe it is reporting the wrong version (it was the version you uploaded in late December or early January). I was about to update yesterday to the very latest, but I didn't want to introduce any more new issues.

    Once I've used an inventory item, the text just sticks and doesn't return to anything else: https://gfycat.com/hatefulcreamyamurstarfish If I remove the script and the second text item, it works fine, but as you can see, they're not even enabled when this is happening.

    I believe this script was written as closely as I could to your suggested method of doing this a year or so ago, I would have preferred a better solution (or a built-in one) but I was really just trying to get anything working as best as I could. If there could be a way of somehow incorporating any of this into AC for a really close Scumm interface, it would be a real help.

  • edited April 2020

    Sorry, it was 1.66.4

    Please be clear. Was that were you upgrading from, or what you are now using?

    Even if it's only in a backup/duplicate project, you should test the latest release to check if this was an issue that's since been addressed. Please also follow my suggestions above to debug what's going on.

    If there could be a way of somehow incorporating any of this into AC for a really close Scumm interface, it would be a real help.

    I can look into it, but familiar with it though I am - I'll need more than just "make it like Scumm". If you can make a point-by-point list of precisely the verb line behaviour you're looking for, I can see about providing something.

  • The previous version that worked fine was 1.66.4 before I upgraded to 1.67.0, where it stopped working. I've described how it should work in detail throughout this thread:

    • Text should flash briefly white when clicked to walk to anywhere.
    • When a hotspot is interacted with, the text should hold white and hold the sentence preventing any changes to the sentence until the player has reached it.
    • During the interaction, the text should still hold white and the sentence, until the interaction is completed.
    • If it is a background action, the text should return to usual when the player reaches the hotspot, rather than when the background interaction has completed, which I think happens anyway in AC.

    You can see this is what I was able to do in the previous AC version, but for some reason it isn't working as well anymore.

  • And what of my suggestions above?

  • edited April 2020

    KickStarter.playerInteraction.GetHotspotMovingTo() isn't the issue (though I tested it with a print as you suggested, it works fine), the moving to hotspots works fine, it's just the inventory interactions that get stuck holding the line, as you can see from the video. I also tested OnEndActionList with a print, and it works fine for anything except for inventory interactions. Nothing seems to happen at the end of an inventory interaction that resets the text anymore, does an inventory interaction finishing not trigger OnEndActionList?

    I realize that this was broken up between two threads: https://adventurecreator.org/forum/discussion/8318/9-verb-sentence-light-up-and-hold#latest

  • Some examples:
    Walk to, hold text white, hold text and hold white: https://gfycat.com/amusingmaledogfish

    Hold during interaction: https://gfycat.com/lividelaboratearthropods

  • This may need a bit more tweaking yet, but should get you most of the way there:

    https://paste.ofcode.org/uBkPvhf2EVRFXEESL3C9vK

    You'll need to comment out the OnHotspotReach event mentions in OnEnable/OnDisable until the next release, but that should fix the line not clearing when an Interaction runs in the background once it's ready.

  • edited April 2020

    Thanks, I've commented out the lines but I'm getting a lot of
    ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) (at <437ba245d8404784b9fbab9b439ac908>:0) System.ThrowHelper.ThrowArgumentOutOfRangeException () (at <437ba245d8404784b9fbab9b439ac908>:0) System.Collections.Generic.List1[T].get_Item (System.Int32 index) (at <437ba245d8404784b9fbab9b439ac908>:0)
    ItemSetLabel.Update () (at Assets/AdventureCreator/Downloads/Nine verbs template/Scripts/ItemSetLabel.cs:47)`

    I'm not sure what this is referring to? I've updated to 1.70.4 and the text still sticks on inventory items (and gives this error at least so we know where it's happening).

    I'm also getting:
    NullReferenceException: Object reference not set to an instance of an object AC.ScummVerbLine.SetOverrideText (System.String text) (at Assets/ScummVerbLine.cs:150) AC.ScummVerbLine.OnEnterGameState (AC.GameState gamestate) (at Assets/ScummVerbLine.cs:82) AC.EventManager.Call_OnChangeGameState (AC.GameState oldGameState) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:254) AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:270)
    when I start the scene. I've set up the prefab like this:

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.