Проблема с NullReferenceExeption
Есть такой кусочек кода. При входе в триггер выдает NullRefExe. Не понимаю, на что ему ссылку нужно дать. Весь текст ошибки:
NullReferenceException: Object reference not set to an instance of an object PreparationToFight.Landing () (at Assets/My Assets/Script/Enemy/PreparationToFight.cs:15) PreparationToFight.OnTriggerEnter (UnityEngine.Collider other) (at Assets/My Assets/Script/Enemy/PreparationToFight.cs:22)
public void Landing()
{
_player.PlayerObj.transform.position = Vector3.MoveTowards(_player.PlayerObj.transform.position, _platform.transform.position, _landingSpeed);
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
Landing();
}
}
Ответы (1 шт):
Автор решения: Алексей Шиманский
→ Ссылка
Ну у вас либо _player null, либо PlayerObj, т.к. по стэку указывает на ту строку