Forum rules - please read before posting.

Inventory item over hotspot, how to show some sort of Over/Out effect

Scenario (works now)

drag item from inventory, item is now the cursor, click on hotspot, action list performs

all works,

I want to have some sort of effect when the itementers and exist the correct hotspot area.

ideally an action list that triggers when entering over the hotspot and another action list that triggers when leaving the hotspot. this way I can create complex setups, animations, effects like I'm already doing now when I'm clicking on the hotspot.

is this possible? and how can I do this?

I can provide a specific use scenario if not clear but i think is better to not complicate the question for now.

Comments

  • You can use the Events Editor to run ActionLists at given times. The Hotspot: Select event, for example, will fire when hovering over a Hotspot.

  • I'm in the Events window, Global events, Hotspot Select and Hotspot Deselect indeed do exactly what I need, I can trigger an Action List.

    But this is blind, it triggers on any hotspot and I can trigger only one action list

    what i need is to trigger a different action list depending of what inventory item is selected and if the correct hotspot is selected.

    maybe like these fields in the inventory item settings

    can i add a custom event to this or something like that?

  • You can attach the Event Runner component to a Hotspot within the scene to have it run the Hotspot: Select event only when that specific Hotspot is selected.

    What's the exact effect you're ultimately looking to achieve? If you're looking to have a unique reaction depending on both the Hotspot and the selected item, then you're better off with a custom script attached to each Hotspot where you can supply that data on a per-instance basis.

    For example:

    using UnityEngine;
    using AC;
    
    public class HotspotSelectExample : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnHotspotSelect += OnHotspotSelect; }
        private void OnDisable () { EventManager.OnHotspotSelect -= OnHotspotSelect; }
    
        private void OnHotspotSelect (Hotspot hotspot)
        {
            if (hotspot.gameObject == gameObject)
            {
                if (KickStarter.runtimeInventory.SelectedItem != null)
                {
                    int itemID = KickStarter.runtimeInventory.SelectedItem.id;
                    Debug.Log ("Hovering over " + hotspot + " with item " + KickStarter.runtimeInventory.SelectedItem.label + " selected");
                    // ...
                }
            }
        }
    
    }
    
  • edited September 2024

    I have a separate inventory that has "Tools" inside. For example a camera. When I'm dragging the camera item from the inventory I want to have controls over some aspects in the scene

    So player moves camera over scene and the scene is blurry&black and white. Then if is on the correct hotspot the scene blur is removed and the color is back. so player knows to click on that hotspot.

    so all these effects I already know how to do it I wanted something to be triggered automatically because the hotspot has the "Inventory" with a precise item selected and will react only to that inventory item.

    But that is ok, I will try the script above that appear to do the trick, I will update the thread let you know if it worked. thank you

    Now that I'm thinking about it I need an event that triggers when a specific inventory item is selected in the inventory. I will check the scripting reference, should be the same as the script you have provided, once triggered it will check if item is the one that I want to do some actions to.

    I think is OnInventorySelect

    there is also OnInventorySelect_Alt I don't understand the difference,

  • OnInventorySelect / OnInventorySelect_Alt will both trigger when an item is selected. The difference between them is only the parameters that get passed - with the latter passing both the item's instance as well as its source. If unsure, use this - it'll give you more to work with.

    With this event, you can extract the selected item's ID to know which item was selected. You can also use the GetProperty function to access additional data you may have assigned to it via the Properties tab:

    void OnInventorySelect_Alt (InvCollection invCollection, InvInstance invInstance)
    {
        int itemID = invInstance.ItemID;
        var property = invInstance.GetProperty ("MyProperty");
    }
    
  • Ok I've got this working, I'm posting here the complete setup I've did if anyone needs this in the future.

    Starting with having a hotspot trigger a specific action list asset when a precise inventory item cursor enters or exist the screen area of the hotspot

    first create a hotspot and in the Inventory Interaction add an inventory item and an action list to run when the click happens. this inventory item is required later for the custom script.

    add this script as component to the hotspot

    using UnityEngine;
    using AC;
    
    public class HotspotSelectDeselect : MonoBehaviour
    {
        //set these action list assets files on the hotspot replace with ActionList if you want the to run in scene acetion lists
        public ActionListAsset hotspotSelectedActionList;
        public ActionListAsset hotspotDeselectedHotspotActionList;
    
        private void OnEnable() { EventManager.OnHotspotSelect += OnHotspotSelect; EventManager.OnHotspotDeselect += OnHotspotDeselect; }
        private void OnDisable() { EventManager.OnHotspotSelect -= OnHotspotSelect; EventManager.OnHotspotDeselect -= OnHotspotDeselect; }
    
        private void OnHotspotSelect(Hotspot hotspot)
        {
            //check if you have inventory item as cursor
            if (KickStarter.runtimeInventory.SelectedItem != null)
            {
                //we check if the cursor item id is the same as the inventory item set on the hotspot
                if (hotspot.invButtons[0].invID == KickStarter.runtimeInventory.SelectedItem.id)
                {
                    //we trigger the cutoms action list
                    hotspotSelectedActionList.Interact();
                }
            }
        }
    
        private void OnHotspotDeselect(Hotspot hotspot)
        {
            if (KickStarter.runtimeInventory.SelectedItem != null)
            {
                if (hotspot.invButtons[0].invID == KickStarter.runtimeInventory.SelectedItem.id)
                {
                    hotspotDeselectedHotspotActionList.Interact();
                }
            }
        }
    
    }
    

    then add the action lists to the component variables fields.

    ok that is it.

    limitations. this works with only one inventory item set on the hotspot interaction list, the first one. if you want more inventory lists then you need to modify the script to check for others, you should use something like hotspot.invButtons[1].invID or hotspot.invButtons[2].invID

    ok now for the part of triggering an action list when a specific inventory item is selected, that is more simple you don't need a script for this.

    you open the Events Editor window and you create two global events: Inventory Select and inventory Deselect. You set the inventory item and the action list to run. that's it

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.