C# 使用Unity时出现NullReferenceException问题 困扰三天..

如题,U3d小白,搜索到的很多相似问题都无法解决,困扰了三天只能上来求助了……

Unity报错:NullReferenceException: Object reference not set to an instance of an object
Enemy_2.Start () (at Assets/_Scripts/Enemy_2.cs:21)

问题出现在21行

 

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

public class Enemy_2 :Enemy
{
    [Header("Set in Inspector:Enemy_2 ")]
    public float sinEccentricity = 0.6f;
    public float lifeTime = 10;

    [Header("Set Dynamically:Enemy_2 ")]
    public Vector3     p0;
    public Vector3     p1;
    public float birthTime;

    // Start is called before the first frame update 

    void Start()
    {
        p0 = Vector3.zero;
        p0.x = -bndCheck.camWidth - bndCheck.radius;
        p0.y = Random.Range(-bndCheck.camHeight, bndCheck.camHeight);

        p1 = Vector3.zero;
        p1.x = bndCheck.camWidth + bndCheck.radius;
        p1.y = Random.Range(-bndCheck.camHeight, bndCheck.camHeight);


        if (Random.value > 0.5f)
        {
            p0.x *= -1;
            p1.x *= -1;
        }
        birthTime = Time.time;

    }
    public override void Move()
    {
        float u = (Time.time - birthTime) / lifeTime;
        if (u >1)
        {
            Destroy(this.gameObject);
            return;
        }
        u = u + sinEccentricity * (Mathf.Sin(u * Mathf.PI * 2));
        pos = (1 - u) * p0 + u * p1;

    }


}
 

bndCheck 变量没有定义和赋值就使用