Forum rules - please read before posting.

How to detect which hotspot your hovering over

Hi, I was just wondering is there a way to detect which hotspot you are hovering over. I have an interaction where when you are over a hotspot you either press E for Take or Q for examine now this has worked if you are on a hotspot but I need a check to see what hotspot you are hovering over otherwise it won't work.

Comments

  • I worked it out by changing how I am handling hotspots. I changed to context-sensitive and used interactionA as the E key and interactionB as the Q key and it works. E is to take the item and Q is to examine the item.

  • New problem doing this way still activates left and right mouse button for hotspot where I only want the E and Q keys to interact not left and right mouse button.

  • Did you unbind the original InteractionA and InteractionB inputs in Unity's input manager? The ones bound to the clicks?

  • What do you mean I have only InteractionA and InteractionB with just E and Q keys in them.

  • Even if I have no keys in InteractionA or B it still gives me the mouse clicks.

  • I thought I didn't need to know how to detect what hotspot your mouse is hovering over but I have come to realize I still need to know that. Because 1 hotspot I need an interaction menu to say E Take and Q Examine but on another hotspot, I need to say just Q Examine. Is there a way to achieve this or Chris are you able to add that feature if there isn't a way to do it now.

  • edited October 2019

    You can prevent mouse clicks from having a default effect by unchecking Mouse clicks have default functionality? in the Settings Manager.

    You can hook into the OnHotspotSelect custom event to react differently according to whether or not the Hotspot has a "Use" interaction defined. See the Manual's "Interaction scripting" chapter as well as the Hotspot class entry in the Scripting Guide.

    using UnityEngine;
    using AC;
    
    public class HotspotContextExample : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnHotspotSelect += OnSelect;
        }
    
        private void OnDisable ()
        {
            EventManager.OnHotspotSelect -= OnSelect;
        }
    
        private void OnSelect (Hotspot hotspot)
        {
            if (hotspot.HasContextUse () && hotspot.HasContextLook ())
            {
                // Hotspot has use and examine interactions
            }
            else if (hotspot.HasContextLook ())
            {
                // Hotspot has just an examine interaction
            }
        }
    
    }
    
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.