Hey! I am not using text-bubble based dialogue in my game (I'm essentially using the base WRPG type template).
With that, I was wondering if there was a relatively easy built-in way to show an indicator (not a quest indicator) over the current speaking actor's head (like the icon of a speech bubble with '...' to indicate they're the one currently speaking). I searched all over the forum/documentation and could only find references to quest indicators, though I want this indicator over the head of whoever is speaking at any given time, regardless of quests.
Thank you, and I'm loving the plug-in so far!
Active Speaker Overhead Indicator
Re: Active Speaker Overhead Indicator
Hi,
You can use a script with an OnConversationLine method to show the indicator. Here's a basic example:
First, say each character has a simple script like the one below to manage its overhead indicator:
Then add a script to the Dialogue Manager, something like:
You can use a script with an OnConversationLine method to show the indicator. Here's a basic example:
First, say each character has a simple script like the one below to manage its overhead indicator:
Code: Select all
public class Speaker : MonoBehaviour
{
public GameObject indicator;
}
Code: Select all
public class SpeakingIndicatorManager : MonoBehaviour
{
private Speaker lastSpeaker;
void OnConversationLine(Subtitle subtitle)
{
if (string.IsNullOrEmpty(subtitle.formattedText.text)) return; // Line is empty; don't show indicator.
if (lastSpeaker == null || subtitle.speakerInfo.transform != lastSpeaker.transform)
{
if (lastSpeaker != null) lastSpeaker.indicator.SetActive(false);
var currentSpeaker = subtitle.speakerInfo.transform.GetComponent<Speaker>();
currentSpeaker.indicator.SetActive(true);
lastSpeaker = currentSpeaker;
}
}
void OnConversationEnd(Transform actor)
{
if (lastSpeaker != null) lastSpeaker.indicator.SetActive(false);
lastSpeaker = null;
}
}
Re: Active Speaker Overhead Indicator
Thank you for the example Tony, this makes a lot of sense. You rock!
Re: Active Speaker Overhead Indicator
Glad to help. Thanks for using the Dialogue System!
Re: Active Speaker Overhead Indicator
Hi
Just got the Dialogue System and it is working wonderfully, i stumbled on this post which sounds exactly like what i am looking for, i am trying to implement the scripts for a simple test, I wanted to confirm that with the "SpeakingIndicatorManager" script, it needs to use the "using PixelCrushers.DialogueSystem;" for the "OnConversationLine" to work? (Specifically the "Subtitle" aspect of the method)
I am very new to all this but i am very keen to learn, and thank you for making such a great System.
Just got the Dialogue System and it is working wonderfully, i stumbled on this post which sounds exactly like what i am looking for, i am trying to implement the scripts for a simple test, I wanted to confirm that with the "SpeakingIndicatorManager" script, it needs to use the "using PixelCrushers.DialogueSystem;" for the "OnConversationLine" to work? (Specifically the "Subtitle" aspect of the method)
I am very new to all this but i am very keen to learn, and thank you for making such a great System.
Re: Active Speaker Overhead Indicator
Yes, that's correct.
Tip: If you type in some code and it doesn't recognize a word such as "Subtitle", you can usually right-click on the word and select a menu option to add the necessary line to recognize it, such as "using PixelCrushers.DialogueSystem;" in this case.
Tip: If you type in some code and it doesn't recognize a word such as "Subtitle", you can usually right-click on the word and select a menu option to add the necessary line to recognize it, such as "using PixelCrushers.DialogueSystem;" in this case.
Re: Active Speaker Overhead Indicator
Thank you!
It is working wonders and the indicators are doing their thing for the NPC's, thank you for the help and to the original poster for this thread.
It is working wonders and the indicators are doing their thing for the NPC's, thank you for the help and to the original poster for this thread.
Re: Active Speaker Overhead Indicator
Great! Glad it's working.