Forum rules - please read before posting.

Change hotspot icon after interacting with it

Hello. I want to make the hotspot icon change after talking to a character to indicate that the character has already been talked to. The icon should return to its normal state if the character has something new to say. Is there an integrated way to do this?

Comments

  • The easiest way to do this is to create a new icon in the Cursor Manager that represents "already talked to", and then use it in a new Interaction in the NPC's Hotspot component.

    If you create a new Use Interaction, and map it to this new icon, you can still assign it the same Interaction ActionList as the regular "Talk to" interaction - so that running either Interaction results in the same response. It's then just a case of disabling it, and running the Hotspot: Change interaction Action to enable/disable it as needed.

  • edited April 2022

    EDIT: Never mind. I found the way. thanks!!!

    I'm not sure I understand. How do I map interactions to a new icon? I'm not using the cursor manager. My game doesn't use the cursor; the character is controlled with the keyboard keys or a gamepad. My Hotspot icon is the one found under Hotspot settings in the Settings Manager. When the character is in the vicinity of a hotspot, the hotspot icon is displayed. Is there a way to change that icon when certain conditions are met?

  • edited April 2022

    I got it to work just like you said. But how would you go about changing the interaction again when the character has something new to say?

    The character says TextA every time you talk to him. After the first time, I can change the interaction so the on subsequent interactions, the other icon is displayed. But something on the scene changes a variable so now the character should say TextB. So when I next approach him, the first icon should be displayed. Is there a way to affect all the characters at once? Or would I need to create a script for it. If so, how can I access those parameters through a script?

  • If you have multiple characters, and they all change their icons at the same time, then using a script may well be appropriate - it really depends on the situation.

    Through script, you can iterate through a Hotspot's useButtons List and update them according to their iconID - which maps an Interaction to an Icon defined in the Cursor Manager. This script, for example, provides two public functions that will update all Hotspots set in its Inspector to show interactions of one icon, and disable interactions of another:

    using UnityEngine;
    using AC;
    
    public class SwitchTalkIcons : MonoBehaviour
    {
    
        public Hotspot[] hotspots;
        public int talkToIconID = 1;
        public int alreadyTalkedToIconID = 2;
    
        public void ShowTalkToIcons ()
        {
            SwitchAllHotspots (talkToIconID, alreadyTalkedToIconID);
        }
    
        public void ShowAlreadyTalkedToIcons ()
        {
            SwitchAllHotspots (alreadyTalkedToIconID, talkToIconID);
        }
    
        private void SwitchAllHotspots (int enableID, int disableID)
        {
            foreach (Hotspot hotspot in hotspots)
            {
                SwitchHotspot (hotspot, enableID, disableID);
            }
        }
    
        private void SwitchHotspot (Hotspot hotspot, int enableID, int disableID)
        {
            foreach (AC.Button button in hotspot.useButtons)
            {
                SwitchButton (button, enableID, disableID);
            }
        }
    
        private void SwitchButton (AC.Button button, int enableID, int disableID)
        {
            if (button.iconID == enableID || button.iconID == disableID)
            {
                button.isDisabled = button.iconID == disableID;
            }
        }
    
    }
    

    To use it, attach to a GameObject in the scene and fill in its Inspector. You can then use the Object: Call event or Object: Send message Actions to trigger its ShowTalkToIcons and ShowAlreadyTalkedToIcons functions when needed.

  • Ok. I tried it and it's not working. I see the change take place in the inspector. My "TalkTo" Interaction gets disabled and "AlreadyTalkedTo" gets enabled, but the icon doesn't change. It still shows the normal "TalkTo" icon. But if I do it through an action list at the end of the conversation and call the Hotspot: Change Interaction action (Once to disable "Talk To", and another time to enable "Already Talked To") it works. However, I can't do that to set them back to "Talk To".

  • I see the change take place in the inspector.

    Is this change the same as when using Hotspot: Change Interaction Actions to update the interaction states?

    At what point are you calling the above script function(s)? At the end of the Conversation?

  • edited April 2022

    The change I saw in the inspector was the same one as when using the Action List. I called the script at the end. I dug around the action lists' scripts and found the Hotspot.ResetMainIcon() function. I added that to my script and it works now.

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.