Dialogue Problems

Hello, Im sorry in advance because I’m extremely new to coding and unity in general.
I’m trying to enable character dialogue using ‘Dialogue Editor’ (see link below) in my 3d first person style game.
I followed all the instructions however when I click on a character to start dialogue I get the error

“NullReferenceException: Object reference not set to an instance of an object”

I am probably missing something super obvious to most but I can’t seem to find the issue in the code or in the inspector.

This is a link to the tutorial I am following :

It’s unlikely this will be super obvious to anyone from what you’ve given. What’s important is where the NullReferenceException is occurring. The full error message includes that information. In addition, if you double-click it, it should take you right to the line of code where the problem was encountered.

Thank you for the response.

NullReferenceException: Object reference not set to an instance of an object
BirdCharacter.OnMouseOver () (at Assets/BirdCharacter.cs:16)
UnityEngine.SendMouseEvents:smile:oSendMouseEvents(Int32)

This is my full error message.

I can see the error would be between the parentheses however this is exactly how the tutorial said to write this script. Here it the full script.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DialogueEditor;

public class BirdCharacter : MonoBehaviour
{
public NPCConversation myConversation;

private void OnMouseOver()

{
if (Input.GetMouseButtonDown(0))
{
ConversationManager.Instance.StartConversation(myConversation);

}

}
}

You’re getting better at asking questions! Next please learn to use the “code” button to paste code.
6219750--683907--upload_2020-8-18_14-21-16.png

That will include line numbers, so we can match up the error to the code. But I guess in this case the problem is on this line:

ConversationManager.Instance.StartConversation(myConversation);

The error says that something on this line is null. And the only object being dereferenced on this line is ConversationManager.Instance. So, apparently ConversationManager.Instance is null.

Now you need to go ask yourself: how is ConversationManager.Instance supposed to not be null? Were you supposed to put ConversationManager on some script in the scene? If so, are you sure you actually did that? Is the thing you put it on active, and is ConversationManager enabled?

I’ll make sure I include that code area next time, thankyou!

I re-added the testconversation into the character’s script and it seems to be working now! I see what you mean that it wasn’t instancing the correct property. (I know it must sound super dumb when the system is screaming the error at me and I still don’t get it >< )

but anyways thank you!

I have more questions now that this part is working but I should probably start a different thread right? :slight_smile:

1 Like

You’re not super dumb; learning to debug takes time and is normal. You’re already doing better than most.

Hang in there! And yeah, start a new thread. :slight_smile:

Thank you my friend :slight_smile: