Prosím Vás jestli nekdo umí v Jave teda v Unity Enginu muže mi prosím někdo opravit tenhle error a říct kde je chyba? Už to delam nekolik hodin a stale nic.. Všechno co jsem za tu hodinu udelal bylo špatně.
Error: NullReferenceException: Object reference not set to an instance of an object
BushTake.OnTriggerEnter (UnityEngine.Collider Col) (at Assets/Inventory/BushTake.js:62)
Script: --- Tam kde je v tom scriptu hrubé písmo to je ten error..
#pragma strict
var respawnBarries : float = 100.0;
var EmptyBarries : boolean = false;
var Barries : GameObject;
var timerisactive : boolean = false;
var guiShow : boolean = false;
var timergui : float = 4.0;
var givebarries : boolean = false;
private var player : GameObject;
public var inventory : Inventory;
function Start () {
}
function Update () {
if(givebarries == true)
{
givebarries = false;
}
if(timerisactive == true)
{
respawnBarries -= Time.deltaTime;
EmptyBarries = false;
}
if(respawnBarries < 0)
{
Barries.SetActive (true);
respawnBarries = 100.0;
}
if(timergui < 0)
{
guiShow = false;
}
}
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "BushPickup")
{
if(EmptyBarries == true)
{
}
if(EmptyBarries == false)
{
Barries.SetActive (false);
EmptyBarries = true;
timerisactive = true;
guiShow = true;
givebarries = true;
player.GetComponent(Inventory).barries += 1;
}
}
}
function OnTriggerExit(Col: Collider)
{
if(Col.tag == "BushPickup")
{
}
}
function OnGUI()
{
if(guiShow == true)
{
GUI.Box(Rect(Screen.width / 5 - 100, Screen.height / 2 - 160, 300, 20), "Barries has been automatically picked up");
timergui -= Time.deltaTime;
}
}