Збрасываеться переменная при запуске игры. Unity

введите сюда описание изображения

Там где Monster и Player после запуска игры в редакторе эти переменные збрасываються и там пишет None.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;

public class pigeon_ai : MonoBehaviour
{
public NavMeshAgent Monster;
public GameObject Player;
// Start is called before the first frame update
void Start()
{
    Monster = gameObject.GetComponent<NavMeshAgent>();
    Player = GameObject.FindGameObjectWithTag("GameController");
}

// Update is called once per frame
void Update()
{
    Monster.SetDestination(Player.transform.position);
    float Dist_Player = Vector3.Distance(Player.transform.position, gameObject.transform.position);
    if (Dist_Player < 1f)
    {
        ReloadLevel();
    }
}

void ReloadLevel()
{
    int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
    SceneManager.LoadScene(currentSceneIndex);
}

}

введите сюда описание изображения

Вот что в иерархии.

введите сюда описание изображения

Ошибка которая появляется при запуске.


Ответы (0 шт):