Forum rules - please read before posting.

Hotspot subtitle to appear at cursor position

So I’m looking to differentiate between some hotspots that open subtitles dialogue, and some that open a little square or information on the hotspot on click beside the cursor position. And then to close once the cursor pulls away. How would I go about doing this?

Comments

  • Are you looking for help with repositioning the Hotspot label, or displaying additional "information"?

    You'll need to share mockups / screenshots to illustrate exactly what you're going for.

  • I would like to display information at the hotspot, but listed like dialogue, where i can use Variable: Run sequence if i needed, or set off an action list or cutscene, but the dialogue is not from a character per se, so not 'spoken', and appears in a designed box next to the hotspot on use or examine and disappears when the cursor moves away? Hope that make sense!

  • You can hook into the OnHotspotSelect / OnHotspotDeselect events to e.g. turn on a menu. That menu could contain a Label element set to display a Global String variable, whose value is set by the script that hooks into the events before turning the menu on.

  • Are you able to get me started with a script for this? Would much appreciate it!

  • I would need the details asked for above.

  • Sorry, which info? I tried to answer your comments from October 8 on oct 9 post

  • You'll need to share mockups / screenshots to illustrate exactly what you're going for.

  • The most convenient way to work with that behaviour is to rely on regular speech Actions in your Hotspot's Interaction. If you use a fake NPC for the speech text, you can limit this NPC's speech text to a specific menu.

    Having things close if the Player clicks/moves the cursor away can come later, but first create a separate Subtitles menu that is styled in the way you have above, set its Position type to Manual, and For speakers of type to Specific Characters Only, and then give it the name of your fake NPC.

    Create an NPC by this same name and keep them hidden from view, but reference this NPC in your Hotspot's speech Action(s).

    Also make sure to exlude this NPC from your regular Subtitles menu.

    To have the menu appear over the Hotspot when clicked, attach this script to the NPC and fill in its Inspector:

    using UnityEngine;
    using AC;
    
    public class SnapMenuToHotspot : MonoBehaviour
    {
    
        public string menuName;
    
        private void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
        private void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
        {
            if (menu.title == menuName)
            {
                Hotspot hotspot = KickStarter.playerInteraction.GetLastOrActiveHotspot ();
                if (hotspot)
                {
                    Vector2 screenPos = hotspot.GetIconScreenPosition ();
                    Vector2 screenPosition = new Vector2 (screenPos.x / ACScreen.width, 1f - (screenPos.y / ACScreen.height));
    
                    screenPosition = new Vector2 (screenPosition.x * ACScreen.width, (1f - screenPosition.y) * ACScreen.height);
                    menu.SetCentre (screenPosition);
                }
            }
        }
    
    }
    
  • ok, so this is currently not working, and I have followed the instructions above, but I have some questions:

    1. Keep NPC hidden - do you mean off screen, or is there an action I should use to 'hide' the npc in the scene?
    2. The speech is currently not over the hotspot
    3. My other Subtitles keep playing even though I have put the FakeNPC in the excluded list.

    See screenshots for detail.

    Thanks!

    https://www.dropbox.com/sh/67o1b3so3e9nglb/AAChB5ANKeXM7K3mgu9lDWgaa?dl=0

  • Keep NPC hidden - do you mean off screen, or is there an action I should use to 'hide' the npc in the scene?

    It can be anywhere in the scene - just don't assign any graphics to it.

    The speech is currently not over the hotspot

    If you're using an AC menu, comment out the line:

    screenPosition = new Vector2 (screenPosition.x * ACScreen.width, (1f - screenPosition.y) * ACScreen.height);
    

    My other Subtitles keep playing even though I have put the FakeNPC in the excluded list.

    Remove the space in your "Character(s) to exclude" field.

  • Thanks, and if i want to offset the new hotspot box to the right or left of the hotspot how would i do that? Cheers Chris!

  • using UnityEngine;
    using AC;
    
    public class SnapMenuToHotspot : MonoBehaviour
    {
    
        public string menuName;
        public Vector2 someOffset;
    
        private void OnEnable () { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
        private void OnDisable () { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        private void OnMenuTurnOn (AC.Menu menu, bool isInstant)
        {
            if (menu.title == menuName)
            {
                Hotspot hotspot = KickStarter.playerInteraction.GetLastOrActiveHotspot ();
                if (hotspot)
                {
                    Vector2 screenPos = hotspot.GetIconScreenPosition ();
                    Vector2 screenPosition = new Vector2 (screenPos.x / ACScreen.width, 1f - (screenPos.y / ACScreen.height));
    
                    screenPosition = new Vector2 (screenPosition.x * ACScreen.width, (1f - screenPosition.y) * ACScreen.height);
                    menu.SetCentre (screenPosition + someOffset);
                }
            }
        }
    
    }
    
  • Hi, having some more positioning issues with this after updating script, see screenshots below:

    https://www.dropbox.com/sh/yd1sal4r45eu05l/AABGFrj54bPWV2Wgy3FMtkLxa?dl=0

  • Please don't crop your screenshots - I need to get the full picture.

    You will, however, need to uncomment the same line as before if you're not using Unity UI:

    screenPosition = new Vector2 (screenPosition.x * ACScreen.width, (1f - screenPosition.y) * ACScreen.height);
    
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.