The referenced object is released as none when playing mode.

I’m coding the script where the dialog comes out, the animation of the character comes out, and the dialog comes out again.

The dialog comes out well, but when the part referring to the character is played, it keeps changing to none, so I want to know what the problem is.

Error Content

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

public class DialogScene1_last : MonoBehaviour
{
    [SerializeField]
    private DialogSystem dialogSystem1;
    [SerializeField]
    private DialogSystem dialogSystem2;

    public HoodMan hood;
    public GameObject smith;
    public GameObject showSword;
    private Animator anim;

    private void Start() {
        smith = GameObject.Find("BlackSmith").GetComponent<GameObject>();
        anim = smith.GetComponent<Animator>();
    }

    private IEnumerator OnTriggerEnter2D(Collider2D collision)
    {
        if (hood.checkTurn)
        {
            if (collision.CompareTag("Player"))
            {
                showSword.gameObject.SetActive(false);
                yield return new WaitUntil(() => dialogSystem1.UpdateDialog());

                int count = 3;
                while (count > 0)
                {
                    count--;
                    yield return new WaitForSeconds(1);
                    // anim.SetBool("Hit", true);
                }
                showSword.gameObject.SetActive(true);
                yield return new WaitUntil(() => dialogSystem2.UpdateDialog());
            }
        }
    }
}

Instead of “smith = GameObject.Find(“BlackSmith”).GetComponent();” i think it should be smith = GameObject.Find(“BlackSmith”);". If you just want to reference the object.