Forum rules - please read before posting.

Left-click to Use, Hover to Examine

Hi everyone,

Hope everyone is doing well :)

From the title, might it be possible to still have the left-click fire "use" interactions while having cursor-hovers fire "examine" interactions (instead of right-clicking) ?

I'm currently using this script from another forum thread to deal with a "description" menu that pops up when hovering over a hotspot, but I'm wondering if it is possible to do this natively with pure AC.

Any help is appreciated, thank you! :smiley:

Comments

  • The use of the OnHotspotSelect custom event is the best way to handle this.

  • Thank you so much! Based on my understanding, would this mean I still require a script for this?

    I was wondering because I am hoping to also change the "description" based on some boolean variables through the game.

  • You would need a script, yes, but you can still have that script run an ActionList to handle the logic that runs.

    Can you elaborate more on exactly what you're looking to do? I'm not clear if you want to adapt the description-box script on the linked thread, or just run a separate ActionList when hovering over a given Hotspot.

  • Yeah for sure!

    So I guess what I'm aiming to do is have a description pop up when hovering over a hotspot. I was wondering if it would be possible to do this without an external C# script -- so something I was hoping to do was repurpose the "examine" interactions from needing to be "right-clicked" and instead just be hoverable.

    The other component of this is that the description of these hotspots may change after events / variable changes, so I am wondering if this would still require an external script.

    Currently, this is what I have here (sorry for some reason I am unable to upload a video directly).

    I'll paste the link here as well in case: https://drive.google.com/drive/u/1/folders/1H8NOeCzpyE0FhLpB7i8zOZ73WyqXwmnY

    When I am hovering over here for example, the description box below pops up.

    This is how it is showing as a component in Unity:
    https://drive.google.com/file/d/1vpwQt70cuIavXmTap2Uy1V07n7X_jhPm/view?usp=share_link

    And this is the current C# script for "Hotspot Description" that I have:

    using UnityEngine;
    using AC;
    
    [RequireComponent(typeof(Hotspot))]
    public class HotspotDescription : MonoBehaviour
    {
        // variable that determines if hovered-description is different for each playable character
        public bool isDifferentForEachCharacter = false;
    
        // description line
        [TextArea] //added for line breaks
        public string description;
        private int stringVariableID = 2; // Set this as appropriate
    
        private void OnEnable() { EventManager.OnMenuTurnOn += OnMenuTurnOn; }
        private void OnDisable() { EventManager.OnMenuTurnOn -= OnMenuTurnOn; }
    
        private void OnMenuTurnOn(Menu menu, bool isInstant)
        {
            if (menu.title == "Description")
            {
                if (KickStarter.playerInteraction.GetActiveHotspot() == GetComponent<Hotspot>())
                {
                    GlobalVariables.SetStringValue(stringVariableID, description);
                }
            }
        }
    
        private void Update()
        {
            if (KickStarter.playerInteraction.GetActiveHotspot() == GetComponent<Hotspot>())
            {
                GlobalVariables.SetStringValue(stringVariableID, description);
            }
        }
    
    }
    
  • Yes, you'd need a script for that.

    It looks like what you have is already working for what you need, but if you wanted a more general-purpose script that simply runs a Hotspot's examine interaction upon hovering over it, you can use this instead:

    using UnityEngine;
    using AC;
    
    public class AutoExamineHotspot : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnHotspotSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnHotspotSelect; }
    
        private void OnHotspotSelect (Hotspot hotspot)
        {
            if (hotspot.gameObject == gameObject)
            {
                hotspot.RunExamineInteraction ();
            }
        }
    
    }
    
  • Perfect, thank you so much! :)

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.