Я следую учебнику по Unity.Я сталкиваюсь с проблемой при попытке обнаружить столкновение в игре.Это ошибка:
NullReferenceException: ссылка на объект не установлена для экземпляра объекта
Это сценарий:
using UnityEngine;
public class Collide : MonoBehaviour
{
public Movement movement; // A reference to our PlayerMovement script
// This function runs when we hit another object.
// We get information about the collision and call it "collisionInfo".
void OnCollisionEnter(Collision collisionInfo)
{
// We check if the object we collided with has a tag called "Obstacle".
if (collisionInfo.collider.tag == "Obstacle")
{
movement.enabled = false; // Disable the players movement.
Debug.Log("Coollision occured");
}
}
}

