Getting Conversation End in Code

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting Conversation End in Code

Post by Tony Li »

It should work if you just type it in manually like you did.

Does the script compile? (In your post, it's missing "using UnityEngine;" but I assume you just omitted it in the post.)

If so, what GameObject is it on?

If it's on the Dialogue Manager, it should work.

If it's on a character GameObject, temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then run the scene and play a conversation. When the conversation starts, look for a line like this in the Console window:

Dialogue System: Starting conversation 'XXX' with actor=AAA and conversant=BBB

where AAA and BBB are GameObjects. Your script's OnConversationEnd method will only be called if the script is on AAA or BBB.
nivlekius
Posts: 105
Joined: Thu Feb 28, 2019 4:39 pm

Re: Getting Conversation End in Code

Post by nivlekius »

I updated the image so you could see better what I mean.

but here is my log:

(Filename: Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs Line: 619)

Dialogue System: Player says 'Did you see a squirrel run by here? No? Yeah me neither.'
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
PixelCrushers.DialogueSystem.ConversationView:StartSubtitle(Subtitle, Boolean, Boolean) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\View\View\ConversationView.cs:125)
PixelCrushers.DialogueSystem.ConversationController:GotoState(ConversationState) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Controller\ConversationController.cs:168)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Controller\ConversationController.cs:224)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\View\View\ConversationView.cs:379)
PixelCrushers.DialogueSystem.ConversationView:OnFinishedSubtitle() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\View\View\ConversationView.cs:386)
PixelCrushers.DialogueSystem.Sequencer:FinishSequence() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:469)
PixelCrushers.DialogueSystem.Sequencer:Update() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:462)

(Filename: Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/View/View/ConversationView.cs Line: 125)

Dialogue System: Sequencer.Play( Delay(4)@0 )
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
PixelCrushers.DialogueSystem.Sequencer:PlayCommand(QueuedSequencerCommand, String, Boolean, Single, String, String, String[]) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:619)
PixelCrushers.DialogueSystem.Sequencer:PlayCommand(QueuedSequencerCommand) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:607)
PixelCrushers.DialogueSystem.Sequencer:PlaySequence(String) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:541)
PixelCrushers.DialogueSystem.Sequencer:PlaySequence(String, Boolean, Boolean) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:551)
PixelCrushers.DialogueSystem.ConversationView:StartSubtitle(Subtitle, Boolean, Boolean) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\View\View\ConversationView.cs:160)
PixelCrushers.DialogueSystem.ConversationController:GotoState(ConversationState) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Controller\ConversationController.cs:168)
PixelCrushers.DialogueSystem.ConversationController:OnFinishedSubtitle(Object, EventArgs) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Controller\ConversationController.cs:224)
PixelCrushers.DialogueSystem.ConversationView:FinishSubtitle() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\View\View\ConversationView.cs:379)
PixelCrushers.DialogueSystem.ConversationView:OnFinishedSubtitle() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\View\View\ConversationView.cs:386)
PixelCrushers.DialogueSystem.Sequencer:FinishSequence() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:469)
PixelCrushers.DialogueSystem.Sequencer:Update() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Sequencer.cs:462)

(Filename: Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Sequencer.cs Line: 619)

Dialogue System: Sequencer: Delay(4)
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
PixelCrushers.DialogueSystem.SequencerCommands.SequencerCommandDelay:Start() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Sequencer\Commands\SequencerCommandDelay.cs:21)

(Filename: Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/MVC/Sequencer/Commands/SequencerCommandDelay.cs Line: 21)

Dialogue System: Stopping conversation because Player (UnityEngine.Transform) exited trigger area.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object, Object)
UnityEngine.Debug:Log(Object, Object)
PixelCrushers.DialogueSystem.DialogueSystemTrigger:CheckOnTriggerExit(Transform) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\Triggers\Triggers\DialogueSystemTrigger.cs:512)
PixelCrushers.DialogueSystem.DialogueSystemTrigger:OnTriggerExit2D(Collider2D) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\Triggers\Triggers\DialogueSystemTrigger.cs:489)

(Filename: Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Triggers/Triggers/DialogueSystemTrigger.cs Line: 512)

Dialogue System: Ending conversation.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
PixelCrushers.DialogueSystem.ConversationController:Close() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\MVC\Controller\ConversationController.cs:126)
PixelCrushers.DialogueSystem.DialogueSystemController:StopConversation() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\Manager\DialogueSystemController.cs:777)
PixelCrushers.DialogueSystem.DialogueManager:StopConversation() (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\Manager\DialogueManager.cs:469)
PixelCrushers.DialogueSystem.DialogueSystemTrigger:CheckOnTriggerExit(Transform) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\Triggers\Triggers\DialogueSystemTrigger.cs:513)
PixelCrushers.DialogueSystem.DialogueSystemTrigger:OnTriggerExit2D(Collider2D) (at Assets\Plugins\Pixel Crushers\Dialogue System\Scripts\Triggers\Triggers\DialogueSystemTrigger.cs:489)
nivlekius
Posts: 105
Joined: Thu Feb 28, 2019 4:39 pm

Re: Getting Conversation End in Code

Post by nivlekius »

And yes my script is on the speaker's object
nivlekius
Posts: 105
Joined: Thu Feb 28, 2019 4:39 pm

Re: Getting Conversation End in Code

Post by nivlekius »

I see it says "Player says" before the text but it is an npc talking and the dialogue has the npc as the actor. So I don't know why that would be.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting Conversation End in Code

Post by Tony Li »

Thanks for updating the image. You won't get a dropdown because OnConversationEnd isn't technically an API call. It's a special function, like Unity's built-in OnTriggerEnter. But unlike OnTriggerEnter there's no special feature in place to make it appear in a dropdown.

As a test, try moving your script to the Dialogue Manager GameObject. Please let me know if it reports "Conversation over".

There should be a line above this one:

Dialogue System: Player says 'Did you see a squirrel run by here? No? Yeah me neither.'

that starts with:

Dialogue System: Starting conversation...

Can you paste that into a reply?

BTW, if the NPC is supposed to say the line above, you may just need to switch the GameObject assignments of Conversation Actor and Conversation Conversant in your Dialogue System Trigger.
nivlekius
Posts: 105
Joined: Thu Feb 28, 2019 4:39 pm

Re: Getting Conversation End in Code

Post by nivlekius »

Ok, it's working now.

OK, that's making more sense. The actor object says ('player') in the tools tips. That was the problem. I, of course, assumed the actor was the one who was speaking but the tooltip says defaults to 'player' in my mind that means the player object. So, basically, my player had been the npc this whole time and vice versa.

So, sorry for this simple issue becoming drawn out. I like to think I'm pretty intelligent but I always have issues that take me forever to solve that end up being the stupidest, most simple solutions.

Thanks a lot for your time.
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Getting Conversation End in Code

Post by Tony Li »

No worries! The Dialogue System is very powerful, but that means it's necessarily a little complicated at times. Sounds like you have to working now though!
Post Reply