Forum rules - please read before posting.

Change the Interaction Method for one Hotspot

Hiya, so for my game, 99% of the time the 'Choose Interaction Then Hotspot' Interaction method works perfectly for what I need. I have one NPC character however which I'd additionally also like to be able to interact by clicking on them with the default cursor.

Is that something that can be scripted/applied to a single hotspot, or would I need to sort out a custom script method for all interactions?

Cheers!

Comments

  • If you're looking to have the Hotspot behave as though you're in 'Context Sensitive' mode, it should just be a case of checking Single 'Use' Interaction? in the Hotspot's Properties box.

  • Thank you for the help! I could mostly make this work for myself, but the ideal setup is to be able to interact with npc using all the different cursor/interaction types, and then also be able to talk to them when clicking with just the default cursor.

    The Single 'Use' Interaction checkbox just means I'm restricted to just one cursor, if I've been using it correctly?

  • edited 5:32AM

    Ah, quite right. Apologies for the misunderstanding.

    In Choose Interaction Then Hotspot mode, the default pointer isn't mapped to any Interaction, so clicking Hotspots won't have an effect. You'd need to rely on a short custom script to detect input and run an ActionList manually.

    Something like this ought to do it:

    using UnityEngine;
    using AC;
    
    public class DefaultClickHotspot : MonoBehaviour
    {
    
        public Hotspot npcHotspot;
        public ActionList actionList;
    
        void Update()
        {
            if (!KickStarter.stateHandler.IsInGameplay()) return;
    
            var hotspot = KickStarter.playerInteraction.GetActiveHotspot();
            if (hotspot == null || hotspot != npcHotspot) return;
    
            var mouseState = KickStarter.playerInput.GetMouseState();
            if (mouseState == MouseState.SingleClick &&
                !InvInstance.IsValid (KickStarter.runtimeInventory.SelectedInstance) &&
                hotspot.provideUseInteraction &&
                !hotspot.IsSingleInteraction() &&
                KickStarter.playerCursor.GetSelectedCursor() == -1)
            {
                actionList.Interact();
            }
        }
    
    
    }
    
  • Thats perfect, I really appreciate 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.