Trouble with actor overrides

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
hannah
Posts: 17
Joined: Mon Feb 22, 2016 10:42 pm

Trouble with actor overrides

Post by hannah »

I'm trying to use the included speech bubble script and everything seems fine accept that suddenly, only one of my speech bubbles is working!

I have no idea what changed. They are identical objects.

Image
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with actor overrides

Post by Tony Li »

Hi,

Make sure the dialogue UI's Find Actor Overrides checkbox is ticked.

Could the Override Unity UI Dialogue UI Controls script have been removed or disabled on the other speech bubbles?

Try temporarily setting the Dialogue Manager's Debug Level to Info. This will add a lot of information to the Console view. As each conversation plays, it will log the Actor and Conversant GameObjects. Make sure they're pointing to the correct GameObjects.

To get rid of those yellow warning messages, add some Text elements to your Dialogue System > Canvas > Dialogue UI > Dialogue Panel and assign them to the corresponding fields on the Unity UI Dialogue UI script. Under normal circumstances, they won't be used, so they'll stay hidden. But they'll suppress those warnings. Also, if the dialogue UI isn't able to find the actor overrides, it will use these Text elements. This might give you another clue to the problem.

If none of those suggestions help, please feel free to send an example to tony (at) pixelcrushers.com. I'll be happy to take a look!

(BTW, cool-looking game!)
hannah
Posts: 17
Joined: Mon Feb 22, 2016 10:42 pm

Re: Trouble with actor overrides

Post by hannah »

Thanks!

Okay so it works correctly now that I've moved the Conversation Trigger from the Main Camera to Cowboy 1 (the actor whose bubble was missing). I'm not sure I quite understand why it works now though.

edit: Another question for you! What's the simplest way to query the state of an actor? Specifically I'd like to know if, on the given frame, Actor 1 is talking. The actors will have a variety of animations states and one of them is for speaking.
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with actor overrides

Post by Tony Li »

hannah wrote:Okay so it works correctly now that I've moved the Conversation Trigger from the Main Camera to Cowboy 1 (the actor whose bubble was missing). I'm not sure I quite understand why it works now though.
If a Conversation Trigger's Actor and/or Conversant properties are unassigned, the Conversation Trigger will try to figure out which GameObjects to use. It will use the Conversation Trigger's GameObject for the Conversant. If the Conversation Trigger is set to OnUse, OnTriggerEnter, or OnCollisionEnter, it will use the triggering object (usually the player) for the Actor.

I'm guessing that the Conversation Trigger's Conversant property is unassigned. Since you moved the Conversation Trigger to Cowboy 1, the Conversation Trigger is now using Cowboy 1 as the Conversant, so now it can find the Override component.
hannah wrote:edit: Another question for you! What's the simplest way to query the state of an actor? Specifically I'd like to know if, on the given frame, Actor 1 is talking. The actors will have a variety of animations states and one of them is for speaking.
I'll describe two ways: in a script and in a sequence.

On any given frame, you can check the DialogueManager.CurrentConversationState property. This is a ConversationState, which is an object that contains information about the current state of the conversation. You can get info about the current actor like this:

Code: Select all

actorName = DialogueManager.CurrentConversationState.subtitle.speakerInfo.Name;
actorTransform = DialogueManager.CurrentConversationState.subtitle.speakerInfo.transform;
However, sequences might be a more convenient way to control animations. That's what they're designed for. You can assign sequencer commands to each dialogue entry node. For example:
  • Dialogue Text: "Howdy, partner!"
  • Sequence: AnimatorPlay(TalkingState); required AnimatorPlay(Idle)@{{end}}
The sequence above sets the current speaker's animator state to "TalkingState". At the end of the subtitle duration (as determined by the subtitle text length and the Dialogue Manager's Subtitle Chars Per Second), it sets the animator state to "Idle". I used the "required" tag in front of the second sequencer command to guarantee that it runs even if the player interrupts the subtitle before it reaches the end duration.

If you want the sequence above to be the default sequence used for all dialogue entry nodes, you can set the Dialogue Manager's Default Sequence field. In this case, leave the dialogue entry node's Sequence field blank. If the Sequence field is blank, the dialogue entry node will use the Dialogue Manager's Default Sequence.
hannah
Posts: 17
Joined: Mon Feb 22, 2016 10:42 pm

Re: Trouble with actor overrides

Post by hannah »

Okay! Very cool.

So I've set up that as the default sequence but it seems to be ending the animation early.
test2.gif
test2.gif (144.92 KiB) Viewed 2202 times
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with actor overrides

Post by Tony Li »

Hi,

From the GIF, it looks like there are two dialogue entries: "Howdy, stranger." and "Care to play a hand or two?...". Is this the case?

If so, it looks like the sequence is only playing on the first dialogue entry. In the second dialogue entry, is the Sequence field set? If so, it wouldn't use the Default Sequence.

Also, please feel free to send an example project to tony (at) pixelcrushers.com any time. I'll be happy to take a look. But I think we should be able to get the final touches done through this forum thread fairly quickly if you prefer.
hannah
Posts: 17
Joined: Mon Feb 22, 2016 10:42 pm

Re: Trouble with actor overrides

Post by hannah »

The forums work fine for me! I like the forums because it has the potential to help someone else in the future.

So yes, they are two separate dialogue entries but neither of them have a default sequence set. it only seems to be a problem when he has two dialogue entries in a row. That's the only time in the conversation that he has two consecutive entries and is also the only time he doesn't animate correctly.
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with actor overrides

Post by Tony Li »

Set the Default Sequence to:

Code: Select all

AnimatorPlay(TalkingState); 
AnimatorPlay(TalkingState)@0.1; 
required AnimatorPlay(Idle)@{{end}}
The problem is that "Howdy, stranger" tells the animator to play the Idle state and -- on the same frame -- the next dialogue entry tells the animator to play the TalkingState. Since the animator is asked to transition to both in the same frame, it gets into a race condition and one transition ends up taking precedence, in your case the Idle state.

The second sequencer command -- AnimatorPlay(TalkingState)@0.1 -- ensures that the animator transitions to TalkingState 0.1 seconds later even if the race condition occurs.

If you wanted to simplify the sequence, you could just use:

Code: Select all

AnimatorPlay(TalkingState)@0.1; 
required AnimatorPlay(Idle)@{{end}}
No one's going to notice a 0.1 second delay at the start of the TalkingState.
hannah
Posts: 17
Joined: Mon Feb 22, 2016 10:42 pm

Re: Trouble with actor overrides

Post by hannah »

Worked like a charm!

New issue! I'm having trouble getting the actor override script to work. I get thrown the following when we try to find the second actor involved in the conversation.

ArgumentNullException: Argument cannot be null.
Parameter name: key
System.Collections.Generic.Dictionary`2[UnityEngine.Transform,PixelCrushers.DialogueSystem.OverrideUnityUIDialogueControls].ContainsKey (UnityEngine.Transform key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:474)
PixelCrushers.DialogueSystem.UnityUIDialogueUI.FindActorOverride (UnityEngine.Transform actor) (at Assets/Tools/Dialogue System/Scripts/Supplemental/UI/Dialogue UI/UnityUIDialogueUI.cs:125)
PixelCrushers.DialogueSystem.UnityUIDialogueUI.ShowSubtitle (PixelCrushers.DialogueSystem.Subtitle subtitle) (at Assets/Tools/Dialogue System/Scripts/Supplemental/UI/Dialogue UI/UnityUIDialogueUI.cs:184)
PixelCrushers.DialogueSystem.ConversationView.StartSubtitle (PixelCrushers.DialogueSystem.Subtitle subtitle, Boolean isPCResponseMenuNext, Boolean isPCAutoResponseNext)
PixelCrushers.DialogueSystem.ConversationController.GotoState (PixelCrushers.DialogueSystem.ConversationState state)
PixelCrushers.DialogueSystem.ConversationController.OnFinishedSubtitle (System.Object sender, System.EventArgs e)
PixelCrushers.DialogueSystem.ConversationView.FinishSubtitle ()
PixelCrushers.DialogueSystem.ConversationView.OnFinishedSubtitle ()
PixelCrushers.DialogueSystem.Sequencer.FinishSequence ()
PixelCrushers.DialogueSystem.Sequencer.Update ()
Screen Shot 2016-02-27 at 6.38.30 PM.png
Screen Shot 2016-02-27 at 6.38.30 PM.png (26.78 KiB) Viewed 2190 times
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Trouble with actor overrides

Post by Tony Li »

Hi,

I'll fix that error message. Unfortunately the fix just missed the version 1.6.0 release that came out today.

Can you name the "Left Cowboy" GameObject the same as the actor's name in your dialogue database?

When a conversation involves more than the original two actors, the Dialogue System finds them in the scene by searching for a GameObject that has the same name as the actor's name in the database. The error message means it didn't find a matching GameObject.
Post Reply