Still doing RPG Dialogue learning and stuck with Dialogue from enemy

I have reached the point where a problem I had before seems to have evolved into something new.
I am at the point where I have AIConversant script added to Enemy8 and the Property for Dialogue set to the New in Town dialogue but when I click the enemy I get a null reference error.
It appears that the Dialogue script DialogUI does not run. Its Start is required to run the establish the callback for the Action event. As that has not happened the invocation for the event dies with the null reference.
I put a Debug.Log in the Start of the DialogueUI but that does not show in the console.
Is there something special about ScriptableObjects (that is what Dialogue is based on) that makes this happen?

I have tried the following. An empty gameObject in the scene has a script attached to it that instantiates a sphere that is public and has been initialised from a prefab of a sphere that has a script attached to it. In that script there is a Debug.Log that has a string in it.
I also placed an instance of the sphere in the scene (representing an NPC) and renamed is SceneSphere.
When I play this the contents of the strings from the spheres appear in the console.
One as SceneSphere and the other Sphere (clone).

So my question is why does the RPG enemy8 not run the attached Dialogue DialogueUI script?

Afternoon, is that the quests and dialogues course?

Yes. I have been through it twice now and cannot seem to find the place where the DialogeUI gets run.
So far I have concluded that the DialogueUI script is not being run.
This script adds the UpdateUI function to the onConversationUpdated event callbacks in its Start function.
So my question now is when is the DialogueUI supposed to get run?
Is there any way to force this script to be run at the time the NPC gets instantiated?

ive moved the post over to Unity Ask with the Quests and Dialogues tag.
should get picked up on there and hopefully get you back on track

The first thing I can think of that would cause the Start() not to run in DialogueUI is if the GameObject it is attached to is inactive when the game starts.
When an object is inactive, Start() and Update() are not run.

At the end of the Start() method, we call UpdateUI(), and the very first line deactivates the DialogueUI gameObject for us, making it safe to leave the gameobject active in the scene file. This way all the necessary hookups can be made, and when we do interact with an AIConversant, the appropriate events will be called, reactivating the Dialogue.

Right found my problem and the solution.
The reason the null reference was coming up was because I had forgotten after accidentally deleting the Dialogue GameObject in the UI Canvas I had omitted the addition of the DialogueUI script that resides in the Asset/Game/UI folder. Once that was added the running of the Start in the DialogueUI was triggered when the Instance of the Dialogue was created as part of the process of clicking the NPC.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms