Bark priority
Bark priority
Hi everyone,
Is there a way to give priorities to barks? I mean if a character barks at random and when my player gets near them I want to play a specific bark. But the problem is that when this specific bark is playing it can be interrupted by this random bark. I can't disable this random barks, because they are run from AC, as well as this specific bark. So I would need to give barks a priority and play them only if their priority is higher then currently playing bark. I know that there are priorities but as I tested them, they don't work that way and from what I understand, they are meant for something different.
Is there a way to give priorities to barks? I mean if a character barks at random and when my player gets near them I want to play a specific bark. But the problem is that when this specific bark is playing it can be interrupted by this random bark. I can't disable this random barks, because they are run from AC, as well as this specific bark. So I would need to give barks a priority and play them only if their priority is higher then currently playing bark. I know that there are priorities but as I tested them, they don't work that way and from what I understand, they are meant for something different.
Re: Bark priority
Hi,
There is no built-in priority to block barks. The Priority dropdown (Normal, AboveNormal, BelowNormal, etc.) specifies the order in which the Dialogue System should check entries when looking for a valid entry to use.
However, here are two ways to block the random bark.
First, let's say you have an NPC "Fred" with two bark conversations: "Specific Barks" and "Random Barks":
Specific Barks
Option #1: Disable the Bark On Idle component.
This only works if you're using Bark On Idle, of course. Use the SetEnabled() sequencer command to temporarily disable the Bark On Idle component during the specific bark:
Specific Barks
Option #2: Use a variable to block the random bark.
Define a Boolean variable such as "Fred_IsBarkingSpecific".
In Specific Barks, use the SetVariable() sequencer command to set the variable true while the bark is playing:
Specific Barks
Random Barks
There is no built-in priority to block barks. The Priority dropdown (Normal, AboveNormal, BelowNormal, etc.) specifies the order in which the Dialogue System should check entries when looking for a valid entry to use.
However, here are two ways to block the random bark.
First, let's say you have an NPC "Fred" with two bark conversations: "Specific Barks" and "Random Barks":
Specific Barks
- "Welcome to our town, stranger!"
- "It sure is cloudy today."
- "A bit chilly, too."
- "I wonder if it will rain."
Option #1: Disable the Bark On Idle component.
This only works if you're using Bark On Idle, of course. Use the SetEnabled() sequencer command to temporarily disable the Bark On Idle component during the specific bark:
Specific Barks
- "Welcome to our town, stranger!"
Sequence: SetEnabled(BarkOnIdle,false,Fred); SetEnabled(BarkOnIdle,true,Fred)@{{end}}
Option #2: Use a variable to block the random bark.
Define a Boolean variable such as "Fred_IsBarkingSpecific".
In Specific Barks, use the SetVariable() sequencer command to set the variable true while the bark is playing:
Specific Barks
- "Welcome to our town, stranger!"
Sequence: SetVariable(Fred_IsBarkingSpecific,true); SetVariable(Fred_IsBarkingSpecific,false)@{{end}}
Random Barks
- "It sure is cloudy today."
Conditions: Variable["Fred_IsBarkingSpecific"] == false - "A bit chilly, too."
Conditions: Variable["Fred_IsBarkingSpecific"] == false - "I wonder if it will rain."
Conditions: Variable["Fred_IsBarkingSpecific"] == false
Re: Bark priority
Thank you for your answer and solutions . It is a pity that there isn't a priority for barks, because both solutions won't work in my situation (too many barks to specify variable for all of them and check them independently )
Re: Bark priority
I'll look into adding bark priority in the next release. You're the first person to ask for it, but it's a great idea.
Re: Bark priority
That's great . Unfortunately we need it in near future, so I have an idea how to implement it in a dirty way. I want to remember priorities in some other script and than attach my script to bark events and save them on dictionary with information about actor and priority. However I can't get any events when bark starts or ends. According to documentation: http://www.pixelcrushers.com/dialogue_s ... vents.html
Is there a way to attach my script to bark events directly and get which character is barking?
Big plus if it is possible to get "Dialogue Entry": http://www.pixelcrushers.com/dialogue_s ... entry.html of the bark. Then I can add priority field (and if there is no such field I can just assume that it has the lowest priority).
I should be able to get all bark events by attaching it to Dialogue Manager, but unfortunately adding it to the Dialogue Manager does nothing and adding it to every character and setting it to send messages to one script is cumbersome.Add this component to the Dialogue Manager or any character that you want to handle events.
Is there a way to attach my script to bark events directly and get which character is barking?
Big plus if it is possible to get "Dialogue Entry": http://www.pixelcrushers.com/dialogue_s ... entry.html of the bark. Then I can add priority field (and if there is no such field I can just assume that it has the lowest priority).
Re: Bark priority
The next update (with bark priority) will be released early next week, probably Monday.
In the meantime, make sure your script methods have the right syntax and you're using methods that will be called on the Dialogue Manager. (See Script Messages.) OnBarkStart and OnBarkEnd are not sent to the Dialogue Manager. Only OnBarkLine is sent to the Dialogue Manager. Try attaching this to the Dialogue Manager:
Alternatively, you can add a Dialogue System Events component to the Dialogue Manager:
Then you can assign a method on any GameObject similar to how you would assign a method to a UI Button's OnClick() event.
(Note that, once again, the Dialogue Manager will only handle OnBarkLine events, so don't assign anything to the OnBarkStart or OnBarkEnd events.)
In the meantime, make sure your script methods have the right syntax and you're using methods that will be called on the Dialogue Manager. (See Script Messages.) OnBarkStart and OnBarkEnd are not sent to the Dialogue Manager. Only OnBarkLine is sent to the Dialogue Manager. Try attaching this to the Dialogue Manager:
Code: Select all
using UnityEngine;
using PixelCrushers.DialogueSystem;
public class BarkLogger : MonoBehaviour {
void OnBarkLine(Subtitle subtitle) {
var priority = Field.LookupInt(subtitle.dialogueEntry.fields, "Priority");
Debug.Log("OnBarkLine: " + subtitle.speakerInfo.Name + ": " + subtitle.formattedText.text +
", Priority: " + priority, subtitle.speakerInfo.transform);
}
}
Then you can assign a method on any GameObject similar to how you would assign a method to a UI Button's OnClick() event.
(Note that, once again, the Dialogue Manager will only handle OnBarkLine events, so don't assign anything to the OnBarkStart or OnBarkEnd events.)
Re: Bark priority
Wow, I thought it will take longer till next release. In that case it is not a problem to wait a little longer . Thank you for everything.
Re: Bark priority
You're welcome! It's going to be a relatively small maintenance release with only a few new features such as bark priority.
Re: Bark priority
Hi,
I updated the Dialogue System, but I don't see where to change the priority for barks. Could you tell me where can I change it? Are they the same as the links priority?
I updated the Dialogue System, but I don't see where to change the priority for barks. Could you tell me where can I change it? Are they the same as the links priority?
Re: Bark priority
Hi,
It's not a built-in dropdown. You must add a custom Number field named "Priority". More details here. If you have any difficulty setting this up, please let me know. I'll be happy to help.
It's not a built-in dropdown. You must add a custom Number field named "Priority". More details here. If you have any difficulty setting this up, please let me know. I'll be happy to help.