conversationController is sometimes null

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Paddy K
Posts: 7
Joined: Tue Dec 10, 2024 7:25 pm
Location: Stockholm

conversationController is sometimes null

Post by Paddy K »

This has been driving me nuts. We are using two dialogue databases, one for dialogues used on a particular level, and one called "Global" for texts that can be used anywhere (opening doors etc). But sometimes - and only sometimes - when I try to start a converation in the Global database I find that the conversationController is null and the dialogue can't start.

There are no differences between the databases that I can see (except that Global has only some of the Actors that are in the other database, since it has fewer dialogues). For example, I do:

DialogueManager.AddDatabase(database);
DialogueManager.StopAllConversations();
DialogueManager.StartConversation(conversation);
DialogueManager.Instance.SetActorPortraitSprite("Player", playerPortait);

And then right after I get a crash from these lines:
DialogueManager.Instance.conversationController.actorInfo -> NULL
DialogueManager.Instance.conversationController.conversantInfo -> NULL
DialogueManager.Instance.conversationModel -> NULL (which is also read from conversationController, I see in the code)

Ans delving some more in the code I find that DialogueManager.instance.FindActorTransformFromConversation is returning null when it looks for "Actor". What can be causing all this to happen?
User avatar
Tony Li
Posts: 23254
Joined: Thu Jul 18, 2013 1:27 pm

Re: conversationController is sometimes null

Post by Tony Li »

Hi,

It should be okay that "FindActorTransformFromConversation" returns null (i.e., it shouldn't crash) -- but to make sure GameObjects get assigned they way you want, please see: Character GameObject Assignments.

If you're playing in the Unity editor's play mode, do any red errors appear in the Console window? If so, please click on the first one, press Ctrl+C to copy its details to the clipboard, and paste them into a reply here.
Paddy K
Posts: 7
Joined: Tue Dec 10, 2024 7:25 pm
Location: Stockholm

Re: conversationController is sometimes null

Post by Paddy K »

Thanks for a speedy reply as always! I actually fixed it. I now save a reference to whatever database I'm using and do:

DialogueManager.RemoveDatabase(lastUsedDatabase);

Before I call:

DialogueManager.AddDatabase(database);

It seemed that some of the previous database's data was still hanging around and it needed to be explicitly removed. But now it works!
User avatar
Tony Li
Posts: 23254
Joined: Thu Jul 18, 2013 1:27 pm

Re: conversationController is sometimes null

Post by Tony Li »

Great! Glad you found the solution.
Post Reply