Forum rules - please read before posting.

Displaying syntax sentences (Hotspot then Interaction)

Hi, a long-time lurker here, first time posting. I have a beginner question regarding displaying the syntax sentence, command line or whatever it is "officially" called...

When using the Interaction Method "Hotspot then Interaction", merely the object labels areshown onscreen by default, even when interactions are chosen/hovered on. I would like for the complete syntax sentence to be displayed onscreen when you hover on a specific interaction before clicking.

For example, when there are multiple use interactions available for an object (say a banana) and you hover on the "look at" or "pick up" cursor icons, the mere "banana" text would update into "look at banana", "pick up banana" etc.

It feels to me like this is probably almost a "tick of a box" type of thing as it is built-in in the 9-verb template, but after searching here, googling and reading the manual I was unable to find really any documentation about this. My apologies if I have overlooked something.

Thanks beforehand!

Comments

  • Welcome to the community, @luuk.

    The 2D Demo should have this behaviour as well. The option to control this is the Cursor Manager's Prefix cursor labels? option under the "Hotspot cursor" settings.

  • Thank you @ChrisIceBox, and thanks for this great asset! So it was as simple as I thought.

    In one scene, I have an object that can be moved left or right. Is it possible to edit the syntax from the default "move left object" to a more grammatically correct "move object left" so that the object's label is printed in the middle of the command?

  • edited May 2021

    It would require scripting - there are too many variations with language in general to provide that kind of control in an Editor.

    Try this:

    1/ In your Variables Manager, create a Global String variable named e.g. "Hotspt override", which we'll use to display a modified (through script) version of the original label
    2/ Then in the Menu Manager, go your Hotspot menu, select the HotspotLabel element, and set the "Label type" to "Global Variable", and map it to "Hotspot override".
    3/ Then paste the code below into a C# file named OverrideHotspotLabel.cs, and attach to a GameObject in your scene:

    using UnityEngine;
    using AC;
    
    public class OverrideHotspotLabel : MonoBehaviour
    {
    
        private GVar variable;
    
        void Start ()
        {
            variable = GlobalVariables.GetVariable ("Hotspot override");
        }
    
        void Update ()
        {
            string original = KickStarter.playerMenus.GetHotspotLabel ();
            variable.TextValue = GetOverrideText (original);
        }
    
        string GetOverrideText (string original)
        {
            Hotspot activeHotspot = KickStarter.playerInteraction.GetActiveHotspot ();
            if (activeHotspot == null) return original;
    
            if (original.StartsWith ("Move left"))
            {
                return "Move " + activeHotspot.GetName (0) + " left";
            }
            if (original.StartsWith ("Move right"))
            {
                return "Move " + activeHotspot.GetName (0) + " right";
            }
            return original;
        }
    
    }
    
  • Aye, this works like a charm. Thank you so much! :)

  • edited May 2021
    @ChrisIceBox, Actually we've since discovered a weird problem with this script. For some reason, it only works in one of our scenes. None of the labels are shown in other scenes. My coder says the bit "KickStarter.playerMenus.GetHotspotLabel ();" finds the correct label there, but not in other scenes.

    I've played some with the different managers, but can't figure out what would cause this scene-specific treatment. I was under the impression all the changes in the managers affect things gamewide.

    My coder tried changing the script so that it doesn't change the KickStarter.playerMenus.GetHotspotlabel ();. As a result, no labels were shown anywhere.

    He also commented that as a ground rule, it would be better form if the code didn't ALWAYS override the label, only when the exception is met...
  • The script doesn't reference or change any Managers - only components present in the Hierarchy at runtime.

    It can only take effect when present in the Hierarchy - if you switch to a scene where it's not present, it can no longer be accessed.

    One option is to place it manually in each of your game's scenes that have Hotspots that require this change to the Hotspot label syntax. Alternatively, you can make it persistent so that it survives scene changes automatically.

    The easiest way to do this is to instead attach it to AC's PersistentEngine prefab - found in /Assets/AdventureCreator/Resources - since this is already set up to survive scene changes.

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.