Forum rules - please read before posting.

Cancel interactions when using the Inventory

Hello, I wonder if it's possible to cancel an interaction when using Inventory items.
The problem I'm having is when I click an interaction on a hotspot (and my character starts walking there) and during the path I interact with my inventory (either by looking an item or combining multiple items), both actions (hotspot+inventory) are messing up, so I wonder how can I cancel the previously clicked interaction (i.e. stopping my player, doing the inventory interaction and forget about the previously clicked hotspot) when handling inventory (p.s. my inventory can be all the time on screen).
I've tried the settings: "Stop player moving when clicking hotspot" but it doesn't work with inventory items.
Thanks!

Comments

  • Can you elaborate on how things are messing up? If there's a bug, it will need to be looked at - please let me know the steps necessary to recreate an issue.

  • Yo dude! Here's what I do:
    KickStarter.player.EndPath();

    It stops the player from moving. Possibly more should be done to cancel any ongoing interaction though?

  • edited August 4

    It's not an actual bug Chris. I mean, for instance, I click a hotspot that switch scene. My player starts walking there.
    Then I look at an item in my inventory (while walking), I've a menu "pop-up" and my player talking describing the item (this triggers the Talk animation, but my player is still walking, so it slides towards the marker of the hotspot). And if it changes scene, the inventory action is interrupted, so my pop-up stays on screen on the next scene, since the actionlist that should close it is not "completed".
    I thought the best thing to do while interacting with an inventory item (looking, using, etc) was to stop the current interaction (as it happens if I click to another on-scene hotspot), but this doesn't happen with inventory items, so I can basically trigger two interactions at the same time.
    Speaking about "trigger", actually the triggers have a "Cancel interactions?". But there isn't an action-list to call that. Nor a setting.
    Am I wrong?

  • Sound like a bug to me.

    I'll look into it, but in the meantime you can cancel pending interactions by hooking into the OnInventoryInteract event:

    using AC;
    using UnityEngine;
    
    public class CancelPendingInteraction : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnInventoryInteract += OnInventoryInteract; }
        private void OnDisable () { EventManager.OnInventoryInteract -= OnInventoryInteract; }
    
        private void OnInventoryInteract (InvItem invItem, int iconID)
        {
            KickStarter.playerInteraction.StopMovingToHotspot ();
        }
    
    }
    
  • Nice, KickStarter.playerInteraction.StopMovingToHotspot(); fixes it better than what I recently did.

    Oh, and you probably want to do the same on the OnInventoryCombine event.

    Thanks Chris!

  • edited August 5

    Thanks a lot to both, Chris and Kloot!
    Will dig into it...

    P.S. isn't the "OnInventoryInteract" including "OnInventoryCombine"?

  • No, he's right - OnInventoryCombine is separate and should be included as well.

    Regardless, this'll be addressed in the next update.

  • edited September 15

    Hello, today I've updated my AC to 1.71.8 (I was using 1.71.4 for the last few months). But I've noticed I still have the issue/bug of my character "sliding" when combining two inventory items after clicking some hotspot interaction (i.e. the inventory interaction is not interrupting the previous hotspot interaction).
    I thought this was suppose to be solved? Am I doing something wrong?
    Maybe the "I'll be addressed in the next update" was about the "Interact" VS "Combine"?
    I've fixed with the above script attached to the PersistentEngine, but I thought it was suppose to be fixed overall!
    thanks

  • Maybe the "I'll be addressed in the next update" was about the "Interact" VS "Combine"?

    It was in reference to the original issue posted - i.e. cancelling a pending Hotspot interaction when using an inventory item.

    As Kloot mentioned, you will also need to do the same thing for OnInventoryCombine if you want the combining items to have the same effect:

    using AC;
    using UnityEngine;
    
    public class CancelPendingInteraction : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnInventoryInteract += OnInventoryInteract;
            EventManager.OnInventoryCombine += OnInventoryCombine;
        }
    
        private void OnEnable ()
        {
            EventManager.OnInventoryInteract -= OnInventoryInteract;
            EventManager.OnInventoryCombine -= OnInventoryCombine;
        }
    
        private void OnInventoryInteract (InvItem invItem, int iconID)
        {
            KickStarter.playerInteraction.StopMovingToHotspot ();
        }
    
        private void OnInventoryCombine (InvItem item1, InvItem item2)
        {
            KickStarter.playerInteraction.StopMovingToHotspot ();
        }
    
    }
    

    Again, these will be fixed in the next update.

    How characters animate when walking and talking is a separate issue. What is your character's "Animation engine" set to? If "Sprites Unity Complex", you will need to wire up your transitions such that "standing talking" animations do not play if the "Move speed float" parameter is non-zero.

  • Sorry I thought there was already an update between yesterday and when the problem was addressed.... Anyway, all good, fixing with the script for now!
    Thanks a lot

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.