Page 1 of 1

Only showing interact UI if NPC has something to say

Posted: Fri May 05, 2023 4:11 am
by CattoCat
Hi!
I have an interaction UI that pops up when near to anything with my Interactable script. I'm having trouble making the interact UI only show near NPCs if they have valid entries in their dialogue conversation, and to not show up even if in range if there aren't any entries that can be shown. The conversations are started from a Dialogue System Trigger that each NPC has, so there could be an easy way to reference each NPC's own conversation from there.

Ideally I would prefer doing this in script, because my dialogue entries already have a lot of quest state conditions to keep track of in the Conversation Editor. Thanks in advance!

Re: Only showing interact UI if NPC has something to say

Posted: Fri May 05, 2023 8:01 am
by Tony Li
Hi,

Show your Interact UI only if the conversation currently has a valid entry. You can check DialogueManager.ConversationHasValidEntry(), like the example below:

Code: Select all

var dsTrigger = npc.GetComponent<DialogueSystemTrigger>();
bool hasValidEntry = DialogueManager.ConversationHasValidEntry(dsTrigger.conversation);
if (hasValidEntry) ShowInteractionUI();

Re: Only showing interact UI if NPC has something to say

Posted: Fri May 05, 2023 12:58 pm
by CattoCat
Thank you for the quick reply, it worked perfectly!

Re: Only showing interact UI if NPC has something to say

Posted: Fri May 05, 2023 1:01 pm
by Tony Li
Glad to help!