Only showing interact UI if NPC has something to say

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
CattoCat
Posts: 2
Joined: Fri May 05, 2023 3:54 am

Only showing interact UI if NPC has something to say

Post 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!
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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();
CattoCat
Posts: 2
Joined: Fri May 05, 2023 3:54 am

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

Post by CattoCat »

Thank you for the quick reply, it worked perfectly!
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help!
Post Reply