Forum rules - please read before posting.

9-verb sentence light-up and hold?

I actually thought I'd asked about this, but it doesn't appear I have (unless it got deleted?) but on the Scumm games, a completed sentence (that isn't just clicking on a non-hotspot point) will highlight and hold there until it is broken:
https://gfycat.com/BasicSnarlingLadybird

The sentence will highlight if anything is clicked, but it will just flash for walk-to's that aren't on hotspots such as walk-to markers.

Is this possible with AC or would it require scripting?

Comments

  • Sorry I couldn't edit. I also asked last year about default interactions building a sentence, but the message removed. At present, when right-clicking a default interaction, the sentence doesn't build, it just performs it: https://gfycat.com/ImpossibleFarCurassow

  • Is this possible with AC or would it require scripting?

    It would require a combination of scripting and animation. First add an Animator to your UI Canvas, and create animations to control both "flashes" and "holds" for the verb line, set to run via appropriate animator parameters. I'd suggest:

    1. Make the default Animation empty
    2. A "Flash" animation that triggers when a Trigger named "Flash" is invoked, and transitions back naturally to the default afterwards
    3. A "Hold" animation that triggers when a Bool named "Hold" is True, and transitions back to the default when False.

    You can then incorporate a custom script that controls these Animator parameters. For example, to set "Hold" to True when the Player is moving to a pending Interaction:

    http://pasteall.org/1444299/csharp

    At present, when right-clicking a default interaction, the sentence doesn't build, it just performs it

    Select the "Verb line" Label menu element and check Show pending Interaction while moving to Hotspot?.

  • Thanks, great idea! I'm trying a simple method without animator as I don't require smooth transitions between colors:
    `public class HighlightPendingVerbLine : MonoBehaviour
    {

    public Text text;
    
    
    private void Start ()
        {
            text = GetComponent <Text>();
        }
    
    
        private void Update ()
        {
                bool doHold = false;
    
                if (KickStarter.playerInteraction.GetHotspotMovingTo () != null &&
                        KickStarter.playerCursor.GetSelectedCursorID () == -1)
                {
                        doHold = true;
                }
    
                if (doHold) 
                {
                text.color = Color.red;
                }
                else { text.color = new Color(0, 234, 255); }
    
        }
    

    }`
    As for the "flash", could that be hooked into clicks on non-hotspot area of the game area that isn't the menu? So, for clicking on places to walk or anywhere on the screen that isn't in the verb/inventory menu, would there be a way of doing it with code? I'm not sure exactly which AC hook to use for clicks of this type, but I'd imagine the color could flash in code by triggering a bool and after a couple of frames, the bool could turn off and the color could go back to normal?

    Second question (sorry!) can the sentence line stay holding the sentence against other hovers unless a click breaks it? Here's how I'm trying to get it looking: https://gfycat.com/UnacceptableTemptingGardensnake

    And presently: https://gfycat.com/DistinctFixedDogwoodclubgall

  • Bonus! That exact script above seems to work differently on auto-walk-to hotspots (hotspots with a walk-to cursor interaction that are handled by the 9-verb auto-walk to script that replaces single-click interaction): https://gfycat.com/SpeedyIndolentIndianrockpython - is this because a second click is ignored by auto-walk to script?

  • edited January 2019

    So, for clicking on places to walk or anywhere on the screen that isn't in the verb/inventory menu, would there be a way of doing it with code? I'm not sure exactly which AC hook to use for clicks of this type, but I'd imagine the color could flash in code by triggering a bool and after a couple of frames, the bool could turn off and the color could go back to normal?

    Being able to disable the effect after a couple of frames is why I suggested using Unity UI - it's uses are beyond being able to interpolate.

    To detect clicks not over Hotspots, you can use:

    if (Input.GetMouseButtonDown (0) && KickStarter.playerInteraction.GetActiveHotspot () == null) { }
    

    However, I will look into adding a custom event hook at the moment a point-and-click request is made, which would likely be more appropriate here.

    Second question (sorry!) can the sentence line stay holding the sentence against other hovers unless a click breaks it?

    For that, you'd be best off swapping out the regular verb line Label with another one that remains unchanged during this time. This too could be done with animation, you'd just need to transfer the contents of the original verb line Text box onto the new one, i.e.:

    textBox2.text = textbox1.text;
    
  • edited January 2019

    Thanks for all the suggestions, the animation method works perfectly, I'm just really novice with animation so I wasn't understanding properly, using a 0.2 exit time for the transition from flash-to-default works perfectly. Here's the final code I used if anyone's interested: `
    public class HighlightPendingVerbLine : MonoBehaviour
    {

    private Animator _animator;
    
    
    private void Start()
    {
        _animator = GetComponent<Animator>();
    }
    
    
    private void Update()
    {
        bool doHold = false;
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null &&
                KickStarter.playerCursor.GetSelectedCursorID() == -1)
        {
            doHold = true;
    
        }
        _animator.SetBool("Hold", doHold);
    
        if (Input.GetMouseButtonDown(0) && KickStarter.playerInteraction.GetActiveHotspot() == null)
        {
            _animator.SetTrigger("Flash");
        }
    }
    

    `
    I agree a hook for this would be perfect, at present it highlights if I click on anything rather than just highlighting when I click "in scene". I suppose I could only trigger if the mouse clicks above a certain unit height, but that might be messy.

    Also, I'm trying to get "Hold" to play during a hotspot walk-to (so if I click on a hotspot and the player walks to the hotspot). You mentioned using a walk-to cursor (which I am for auto walk-to's) and adding interaction that for each hotspot as a walk-to marker for fixed hotspot walk-to positioning (ala scumm games). I tried using that as a hold, but it resets if I re-click the hotspot again: https://gfycat.com/ParchedBriskIaerismetalmark any ideas how to get it to hold during walk-to hotspots?

  • Same technique - swap it out for a dummy one until you're ready to show the "live" one again.

  • It's working now with the "walk to" cursor interaction for hold, but it clears upon a second click. I'm using the "auto walk to" script in the scene. I'm using a dummy text verb to not clear the text when hovering during a walk-to:

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

    public class Verb1txtVerb2 : MonoBehaviour
    {

    public Text textBox1;
    public Text textBox2;
    public GameObject bg;
    
    
    
    
    
    private void Update()
    {
    
    
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null 
            )
        {
    
            textBox2.enabled = true;
            bg.SetActive(true);
    
    
        }
        else {
    
            textBox2.text = textBox1.text;
            textBox2.enabled = false;
            bg.SetActive(false);
        }
    
    }
    

    }`

    but a second click on a walk-to hotspot clears it. Does the second click somehow reset playerInteraction.GetHotspotMovingTo() ? Here's a clip: https://gfycat.com/UnhappyUnsightlyHairstreakbutterfly

  • Here's another example with debug on: https://gfycat.com/AlarmedShoddyAmberpenshell

  • Try the updated "AutoWalkTo" script in the nine-verbs template.

  • Thanks, that's perfect! I've fixed it if anyones interested, here's a new version that works with right-click default interactions (it needs to be delayed a frame to build the second sentence text for default interactions):
    `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 void Start()
    {
    
    }
    
    
    private void Update()
    {
    
        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;
        }
    }
    

    }`

  • Is there a way of detecting if the player is already at the location of a walk-to marker relative to the hotspot clicked on? If so, I could compare it to avoid a UI glitch that happens if you click on the same hotspot as its market that you have already arrived at, otherwise I think also delaying it for a frame would solve this. Is this the best way of delaying for a frame, or would you recommend the method used to solve the subtitles glitch with a hook delay (I think it was)?
  • You could try just checking the distance between the two points:

    (myHotspot.walkToMarker.transform.position - KickStarter.player.transform.position).sqrMagnitude
    
  • edited January 2019

    EDIT: I had an error from the auto-walk to if there wasn't an unhandled inventory interaction on the hotspot. Is it possible to add a global unhandled that has a walk-to marker, as each hotspot does?

    ?

  • I don't know what your error was, but the Walk-to Marker is a property of the Hotspot - if you're scripting it, it doesn't matter what the interactions are.

  • The error isNullReferenceException: Object reference not set to an instance of an object AutoWalkTo.OnHotspotInteract (AC.Hotspot hotspot, AC.Button button) (at Assets/AdventureCreator/Downloads/Nine verbs template/Scripts/AutoWalkTo.cs:54) AC.EventManager.Call_OnInteractHotspot (AC.Hotspot hotspot, AC.Button button) (at Assets/AdventureCreator/Scripts/Managers/EventManager.cs:245) AC.PlayerInteraction.ClickButton (InteractionType _interactionType, Int32 selectedCursorID, Int32 selectedItemID, AC.Hotspot clickedHotspot) (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:978) AC.PlayerInteraction.HandleInteraction () (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:757) AC.PlayerInteraction.ContextSensitiveClick () (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:576) AC.PlayerInteraction.HandleInteractionMenu () (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:162) AC.PlayerInteraction.UpdateInteraction () (at Assets/AdventureCreator/Scripts/Controls/PlayerInteraction.cs:98) AC.StateHandler.Update () (at Assets/AdventureCreator/Scripts/Game engine/StateHandler.cs:313) but is it possible to have the player walk-to the hotspots walk-to in a global unhandled? For instance: https://gfycat.com/ScientificLoneKiskadee if "use newspaper on sign" is unhandled (as it probably would be for a combination as unlikely as that!) the unhandled interaction would be dialog saying something like "I can't use those things together", but the player would still want him to walk-to the object first (or in my case, walk-to the marker to emuate the scumm games that had specific walk-to positioning for all hotspots). Is it possible to pass the hotspots walk-to marker through to the unhandled global interaction so he walks-to the marker for each unhandled interaction?

  • The package now addresses the error.

    To have the player walk to the Hotspot as part of an unhandled interaction, pass the Hotspot as the Interaction ActionList's GameObject parameter. If you then perform a Character: Move to point Action to move to that parameter, they'll walk to the Hotspot's Walk-to marker - not the Hotspot itself.

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.
Do NOT follow this link or you will be banned from the site!