Forum rules - please read before posting.

Different types of hotspots enabling different Menus.

Hello everyone,
This is for a 3d side scroller.

Say I need to have 2 (potentially more) types of hotspots (using different tags to be distinguished).

Type 1:
Everyday hotspot, used to interact with objects that are on the same plane as the player;
Type 2:
Navigation hotspot, used to move to rooms that are on a different plane;

I want the two hotspots to use different menus (using UnityPrefab as Source), so that i can decide to use different graphics for each hotspot.

Is there a way to do this without having to modify AC native scripts or ending up having to rewrite the whole Hotspot Detection system with a custom script?

Note:

  • Type1 hotspots can either be "single use" or open an interaction menu;
  • Type2 hotspots will always be "single use";
  • Each menu might have different pivot positioning, so to keep visuals consistent and tidy;
  • Interaction Method: Chose Hotspot Then Interaction;
  • See Interactions with: Custom Script;
  • Close Interactions with: Custom Script;
  • Hotspot Detection Method: Player Vicinity;
  • Hotspot In Vicinity: Nearest Only;
  • Display Hotspot Icons: Via Script Only;

Thanks in advance for your help!

Comments

  • edited November 2020

    Can you share some screenshots to illustrate? What exactly are you populating these menus with? "Single use" Hotspots won't show an Interaction menu when hovered over.

    A custom Hotspot Detection method should only be necessary if you want to change the way in which Hotspots are detected - the way they react when detected is separate.

    It may be that you can achieve what you want by hooking into the OnHotspotSelect custom event - which is triggered when a Hotspot is selected but before any interaction is run.

    You should be able to use this to lock/unlock a pair of Menus based on the Hotspot in question, i.e.:

    using UnityEngine;
    using AC;
    
    public class HotspotMenuLocker : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnSelect; }
    
        private void OnSelect (Hotspot hotspot)
        {
            if (hotspot.gameObject.tag == "NavigationHotspot")
            {
                PlayerMenus.GetMenuWithName ("NavigationHotspot").isLocked = false;
                PlayerMenus.GetMenuWithName ("EverydayHotspot").isLocked = true;
            }
            else
            {
                PlayerMenus.GetMenuWithName ("NavigationHotspot").isLocked = false;
                PlayerMenus.GetMenuWithName ("EverydayHotspot").isLocked = true;
            }
        }
    
    }
    

    (Using example menu / tag names)

  • edited November 2020

    Hello Chris,
    I should have mentioned this project uses direct control, but it will also support mouse and keyboard in the future.

    To answer your question:

    • Navigation hotspots trigger an action list or a cutscene associated;
    • EverydayHotspots open an interaction menu (unless it's a single use);

    Anyway, I have tried it out (simply added it to my scene) and it works just fine but i have noticed a bug.

    When an EverydayHotspot menu is shown, but the player then hits a NavigationHotspot, the EverydayHotspot menu stays visible.

    I have tried having the player entering a NavigationHotspot first and then hitting an EverydayHotspot, but the bug does not happen and the menus work as expected.

    I must clarify that I am using the standard Hotspot menu that comes with AC, along with the custom Hotspot_Navigation I have created.

    Is this happening because there is some piece of code that already handles the hotspot menu differently?

    EDIT:

    Apparently removing the lines of code that were trying to unlock the hotspot menu, solved the issue, however, i can still see the Hotspot menu being visible underneath the Hotspot_Navigation menu.

        using UnityEngine;
        using AC;
    
        public class HotspotMenuLocker : MonoBehaviour
        {
    
            private void OnEnable () { EventManager.OnHotspotSelect += OnSelect; }
            private void OnDisable () { EventManager.OnHotspotSelect -= OnSelect; }
    
            private void OnSelect (Hotspot hotspot)
            {
                if (hotspot.gameObject.CompareTag ("NavigationHotspot"))
                {
                    PlayerMenus.GetMenuWithName ("NavigationHotspot").isLocked = false;
                }
                else
                {
                    PlayerMenus.GetMenuWithName ("NavigationHotspot").isLocked = true;
                }
            }
    
        }
    
  • If you want the EverydayHotspot menu to be disabled when dealing with Navigation Hotspots, you'll need to account for it in the code. The above modified script makes no changes to it, so it will turn on/off as normal.

    Is your EverydayHotspot menu the same as the Interaction menu? Screenshots to illustrate the situation will help my understanding.

    It's also possible to turn a Menu off through scripting:

    PlayerMenus.GetMenuWithName ("EverydayHotspot").TurnOff ();
    

    However, unless a Menu is also locked, it will be turned on again automatically if it's "Appear type" condition is currently met.

  • edited November 2020

    Sorry Chris,
    My bad, i have posted the wrong code.

    using UnityEngine;
    using AC;
    
    public class HotspotMenuLocker : MonoBehaviour
    {
    
        private void OnEnable() { EventManager.OnHotspotSelect += OnSelect; }
        private void OnDisable() { EventManager.OnHotspotSelect -= OnSelect; }
    
        private void OnSelect(Hotspot hotspot)
        {
            if (hotspot.gameObject.CompareTag("NavigationHotspot"))
            {
                PlayerMenus.GetMenuWithName("Hotspot_Navigation").isLocked = false;
                PlayerMenus.GetMenuWithName("Hotspot").TurnOff();
    
    
            }
            else
            {
                PlayerMenus.GetMenuWithName("Hotspot_Navigation").isLocked = true;
                PlayerMenus.GetMenuWithName("Hotspot").TurnOn();
    
            }
        }
    
    }
    

    What happens is that the menu Hotspot_Navigation works as expected, but the menu Hotspot (which is AC standard), does not.

    I have also tried locking the menu, same result.

    PlayerMenus.GetMenuWithName("Hotspot").isLocked = true;

    From the look of it, the Hotspot menu gets triggered even if the Hotspot in question is tagged as NavigationHotspot.

  • edited November 2020

    What's is the Hotspot menu's Appear type?

    If a Menu is turned off manually, it will turn on again automatically if its Appear type condition is currently met.

    If a Menu is locked, however, it will never turn on - which is why it's typically better to lock a menu rather than turn it off, unless it has an Appear type of Manual. That's what my original code above set out to do.

  • Appear type is currently OnHotspot for both menus.

    I have turned it to manual and used the TurnOn/TurnOff code, which made it work.

    However now the menus won't disappear as I am not quite sure how to use the EventManager.OnHotspotDeselect delegate.

  • Inserting that into the above would give the following:

    using UnityEngine;
    using AC;
    
    public class HotspotMenuLocker : MonoBehaviour
    {
    
        private void OnEnable()
        {
            EventManager.OnHotspotSelect += OnSelect;
            EventManager.OnHotspotDeselect += OnDeselect;
        }
    
        private void OnDisable()
        {
            EventManager.OnHotspotSelect -= OnSelect;
            EventManager.OnHotspotDeselect -= OnDeselect;
        }
    
        private void OnSelect (Hotspot hotspot)
        {
            if (hotspot.gameObject.CompareTag("NavigationHotspot"))
            {
                PlayerMenus.GetMenuWithName("Hotspot_Navigation").isLocked = false;
                PlayerMenus.GetMenuWithName("Hotspot").TurnOff();
            }
            else
            {
                PlayerMenus.GetMenuWithName("Hotspot_Navigation").isLocked = true;
                PlayerMenus.GetMenuWithName("Hotspot").TurnOn();
    
            }
        }
    
        private void OnDeselect (Hotspot hotspot)
        {
            PlayerMenus.GetMenuWithName("Hotspot").TurnOff();
        }
    
    }
    

    A list of all Hotspot-related events can be found in the Manual's "Interaction scripting" chapter.

  • This is what ultimately worked for me.

    I am glad I can use/simulate multiple hotspot types, it allows for extra customisation and a clearer design.

    Thanks Chris!

        using UnityEngine;
        using AC;
    
        public class HotspotMenuLocker : MonoBehaviour
        {
    
            private void OnEnable() 
            { 
                EventManager.OnHotspotSelect += OnSelect;
                EventManager.OnHotspotDeselect += OnDeselect;
    
            }
            private void OnDisable() 
            { 
                EventManager.OnHotspotSelect -= OnSelect; 
                EventManager.OnHotspotDeselect -= OnDeselect; 
            }
    
            private void OnSelect(Hotspot hotspot)
            {
                if (hotspot.gameObject.CompareTag("NavigationHotspot"))
                {
                    PlayerMenus.GetMenuWithName("Hotspot_Navigation").TurnOn();
                    PlayerMenus.GetMenuWithName("Hotspot").TurnOff();
    
    
                }
                else 
                {
                    PlayerMenus.GetMenuWithName("Hotspot_Navigation").TurnOff();
                    PlayerMenus.GetMenuWithName("Hotspot").TurnOn();
    
                }
            }
    
            private void OnDeselect(Hotspot hotspot)
            {
                PlayerMenus.GetMenuWithName("Hotspot_Navigation").TurnOff();
                PlayerMenus.GetMenuWithName("Hotspot").TurnOff();
            }
        }
    
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.