- Home /
Question by
ashjack · Feb 01, 2014 at 01:09 PM ·
c#errorupdatenullreferenceexception
NullReferenceException
I know there have been many questions on this before, but each question has had completely different code to mine, and I thought I should ask.
I have started making a player job script, and it works, but whenever I build the project in order to test the multiplayer, it comes up with the error constantly, and it fills up the log box within seconds.
Here is my code:
using UnityEngine;
using System.Collections;
public class PlayerJob : MonoBehaviour {
//0 = Unenmployed
//1 =
public int Job;
public Date date;
public Money money;
public bool payday;
void Start()
{
money.money = 0;
payday = true;
Job = 1;
}
void Update()
{
if(Job == 0&&date.day == 4&&payday == (true))
{
money.money = money.money+0;
payday = false;
}
if(Job == 1&&date.day == 4&&payday == true)
{
money.money = money.money+100f;
payday = false;
}
if(date.day == 5&&payday == (false))
{
payday = true;
}
}
}
Comment
Best Answer
Answer by ashjack · Feb 01, 2014 at 01:22 PM
Sorry, but I worked it out myself. Since I had to instantiate the player via Photon(Multiplayer system) I had forgotten to tell it where to find the "date" script.
I should really look for longer before I post on Unity Answers. Thanks anyway!
AshJack