Forum rules - please read before posting.

Cancel movements on left mouse clicks when an item is selected

Here's what I'm trying to do:
When an item is selected (so it now acts as the cursor), clicking on the screen on non hotspots shouldn't result in a player movement but rather just deselect the item.

Is there a setting for this somewhere? If not, it would be great if EventManager.OnPointAndClick passed along an object with a CancelMovement prop that I could set to true.

Here's a dump of my settings:
https://1drv.ms/i/s!Amz_vh8OYDX3vu1U5tEZGNsZ195Kcg?e=zF0MHv

Thanks

Comments

  • There is an option to prevent movement when an item is selected, but it currently only appears if Left-click deselects active item? is unchecked. I can look into exposing this option when checked, which causes the item to be de-selected, but the Player not move.

  • Much appreciated.

  • This can be achieved by hooking into the OnInventoryDeselect custom event, and halting the Player if it occurs during gameplay:

    using UnityEngine;
    using AC;
    
    public class DeselectingStopMovement : MonoBehaviour
    {
    
        private void OnEnable () { EventManager.OnInventoryDeselect += OnInventoryDeselect; }
        private void OnDisable () { EventManager.OnInventoryDeselect -= OnInventoryDeselect; }
    
        private void OnInventoryDeselect (InvItem invItem)
        {
            if (KickStarter.stateHandler.IsInGameplay ()) KickStarter.player.EndPath ();
        }
    
    }
    
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.