Forum rules - please read before posting.

Inventory Item Cursor question

edited June 2019 in Technical Q&A

Hi,

For my each of my inventory items I have a Main Graphic, Active Graphic and have recently added a Cursor graphic. But since adding the Cursor graphic, when an inventory item is selected the Active Graphic no longer displays over hotspots. It's just the Cursor graphic all the time.

Can anyone help please?

Comments

  • edited June 2019

    As intended - a cursor graphic is a special graphic type so if assigned it should be used always for the cursor.

    If the graphic is animated, however, it can be animated only when hovering over a Hotspot.

  • Noted. Thank you.

  • On this subject, I have another question:

    In my 2D adventure game, I use Context Sensitive interactions. Hotspots are used for areas of interaction as well as areas which when clicked on change to a new room. When I have an inventory item selected and I hover over any of these Hotspots the Active graphic shows.

    Is it possible to define that the Active graphic only shows when over areas which are for the USE interaction and none others?

  • I don't see the link between the "Use" interaction and an Inventory item - did you mean a "Use inventory" interaction, so that it only shows the active graphic if a valid interaction is available?

    If so, you can uncheck Show Active FX when an Interaction is unhandled? in the Settings Manager. Otherwise, you'd have to hook into the OnHotspotSelect custom event to change the Active cursor FX field dynamically according to whether or not the Hotspot has a Use interaction defined.

  • Sorry for the lack of clarity. I think you mostly understood though. I'll ask another related question and try to be clearer:

    When hovering over a Hotspot which displays an ARROW graphic cursor, how can I make the cursor always show that arrow graphic even if I have an inventory item selected?

    This must be a common feature, since most adventure games I have played switch the cursor from whatever I item I have selected to the Exit arrow icon when hovering at the edges of the screen.

  • edited June 2019

    AC won't deselect an item when hovering over a Hotspot, but again you can use OnHotspotSelect for this. If you record the selected item before deselecting it, you can also restore that item afterwards with OnHotspotDeselect.

    Attached to the Hotspot you want this to work for, something like:

    using UnityEngine;
    using AC;
    
    public class HotspotEventTest : MonoBehaviour
    {
    
        private InvItem selectedItem;
    
        private void OnEnable ()
        {
            EventManager.OnHotspotSelect += MySelect;
            EventManager.OnHotspotDeselect += MyDeselect;
        }
    
        private void OnDisable ()
        {
            EventManager.OnHotspotSelect -= MySelect;
            EventManager.OnHotspotDeselect -= MyDeselect;
        }
    
        private void MySelect (Hotspot hotspot)
        {
            if (hotspot == GetComponent <Hotspot>())
            {
                selectedItem = KickStarter.runtimeInventory.SelectedItem;
                KickStarter.runtimeInventory.SetNull ();
            }
        }
    
        private void MyDeselect (Hotspot hotspot)
        {
            if (hotspot == GetComponent <Hotspot>() && selectedItem != null)
            {
                KickStarter.runtimeInventory.SelectItem (selectedItem);
                selectedItem = null;
            }
        }
    
    }
    
  • That looks good and I will try it out. I'm wondering if there is a way to identify all hotspots which change the cursor to an Arrow graphic, and apply this logic to them from one central script, rather than attaching to each hotspot individually?

  • I tried the script. It's almost right, but it exercises the behaviour of Deselecting the inventory item when hovering OFF the hotspot not hovering OVER.

  • Typo in the script above. I've updated it - try it now.

  • Works perfectly!

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.