Forum rules - please read before posting.

Trigger Action List from hotspot on hover (map)

Hello!
I've working on a map but instead of using the Menus (buttons) I tried to use the Hotspots so I could trigger action lists and make good use of all the things the hotspots have. I searched the forum for a solution and found something like this:

using UnityEngine;
using AC;

public class MouseOverHotspot : MonoBehaviour
{
public ActionList onHover;

private void OnEnable()
{
    EventManager.OnHotspotSelect += Hover;
}

private void OnDisable()
{
    EventManager.OnHotspotSelect -= Hover;
}

private void Hover(Hotspot hotspot)
{
    onHover.Interact();
}

}


To test it out simple, I created some sort of glow over the sprite (another sprite which turns visible). Unfortunately it only works on one hotspot disregarding which hotspot I'm hovering over.
I also created a second Action list so when it goes away from the hover, to run another action list to restore everything to normal. Practically same approach but in two different scripts.

Unfortunately, not even making one or two scripts for hotspots I could make it work.
The simple question is: how can I trigger an action list when hovering over a hotspot? And maybe another one when hovering away? If it's possible... of course.
By the way: I did look into the tutorial but we wanted to go a step further.

Thanks.
Latest AC. Unity 2020.3.38

Comments

  • edited September 2022

    If you want to have the "onHover" ActionList run for a specific Hotspot, you need to compare the function parameter with some value. If the script is attached to the Hotspot itself, for example, you can compare its gameObject:

    private void Hover (Hotspot hotspot)
    {
        if (hotspot.gameObject == gameObject)
        {
            onHover.Interact();
        }
    }
    
  • THANKS! Exactly what I was looking for. Thanks again for everything!

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.