Have NPCs bark at each other

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
wedgiebee
Posts: 16
Joined: Wed May 25, 2022 6:40 pm

Have NPCs bark at each other

Post by wedgiebee »

Hi there, I'm struggling to implement a setup where NPCs bark at each other. I know there are instructions in the documentation's FAQ for this very case, but sadly I am still struggling!

I have NPC 1 and NPC 2 who are sitting at a bench. When the player walks within range, the NPCs should start a series of barks at each other, let's say like 4 back-and-forths. If the player leaves range, they should stop, and if the player re-enters range, they should restart from the beginning.

How do I do this?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Have NPCs bark at each other

Post by Tony Li »

Hi,

Since it's a series of lines of dialogue, run a conversation. See: How To: Show Overhead Conversation Bubble Text
wedgiebee
Posts: 16
Joined: Wed May 25, 2022 6:40 pm

Re: Have NPCs bark at each other

Post by wedgiebee »

Got it, thanks for the link! Using a conversation makes sense, but I have some existing behavior that it conflicts with.

1) I have a component on my player character that listens to "DialogueManager.instance.conversationStarted" and "DialogueManager.instance.conversationEnded" to disable/enable player input. I don't want this behavior when the NPCs have a bark conversation - I want the player to still have input as normal, like they're just observing a conversation in the background.

2) I have a component that always sets continue mode to true (meaning require the continue button to be pressed) for conversations. For NPC bark conversations, I want their conversations to progress automatically on a timer.

How would I handle these situations?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Have NPCs bark at each other

Post by Tony Li »

Hi,
wedgiebee wrote: Sun May 12, 2024 5:10 pm1) I have a component on my player character that listens to "DialogueManager.instance.conversationStarted" and "DialogueManager.instance.conversationEnded" to disable/enable player input. I don't want this behavior when the NPCs have a bark conversation - I want the player to still have input as normal, like they're just observing a conversation in the background.
Use OnConversationStart(Transform) and OnConversationEnd(Transform) methods on the player GameObject (or a Dialogue System Events component) instead of DialogueManager.instance.conversationStarted/Ended. These methods will only be called when the player GameObject is used as the primary actor or primary conversant. More info: Character GameObject Assignments
wedgiebee wrote: Sun May 12, 2024 5:10 pm2) I have a component that always sets continue mode to true (meaning require the continue button to be pressed) for conversations. For NPC bark conversations, I want their conversations to progress automatically on a timer.
Instead of using a component, set the Dialogue Manager's Display Settings > Subtitle Settings > Continue Button mode to Always. For NPC bark conversations, inspect the conversation and select Menu > Conversation Properties. Then tick Override Display Settings > Subtitle Settings, and set the Continue Button mode for that conversation to Never.
wedgiebee
Posts: 16
Joined: Wed May 25, 2022 6:40 pm

Re: Have NPCs bark at each other

Post by wedgiebee »

Thank you, this works great!

For the NPC bark conversations, I've gone into their Conversation Properties and ticked Override Display Settings > Subtitle Settings so that I can set Continue Button to Never. But now all those conversation also use their own "Subtitle Chars Per Second" as specified in the overridden subtitle settings. I want all NPC bark conversations to have the same "Subtitle Chars Per Second," and I want to easily be able to tweak that number in all places over the course of development instead of having to go into every NPC bark conversation.

Is there a way to do that with this method?
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Have NPCs bark at each other

Post by Tony Li »

Hi,

Here's another approach:
  • UNtick the conversation properties' Override Subtitle Settings checkbox.
  • Tick Override Camera Settings.
  • Set Default Sequence to something like:

    Code: Select all

    Continue()@{{end}}
    This will simulate a continue button click after a duration based on the text length. (More info on duration: How To: Control the Duration of Subtitle Text)
Post Reply