NullReferenceException:对象引用未设置为对象的实例questgiver.QuestCompleted(字节检查)

时间:2016-01-11 03:52:50

标签: c# class unity3d nullreferenceexception

我从这段代码中收到NullReference异常错误。我正在尝试从Current_AP脚本访问值PM = PlayerMotor,从Previous_Quest_Finished脚本访问nars = nurse_npc。任何帮助将不胜感激。

public nurse_npc nars; //drag and dropped gameobject named nurse
public byte QuestCompleted(byte check)
{
    PlayerMotor pm;
    pm = transform.GetComponent<PlayerMotor> ();


    if(check == 0)
    {
    iscompleted = false;
        //quest is pending
    }
    if(check == 1)
    {
    iscompleted = true;
    onquest = false;
    pm.Current_AP(10);
    nars.Previous_Quest_Finished(1);
    }
    return check;
}

0 个答案:

没有答案