- Home /
This question was
closed Jan 03, 2020 at 03:21 PM by
panim0_unity for the following reason:
The question is answered, right answer was accepted
Question by
panim0_unity · Jan 01, 2020 at 01:35 PM ·
c#unity 5scripting problemphotonpun
Custom Properties, Unity, Object refence not set to an instance of an object
when I control player on masterClient İ get no erros but n the other player that line I marked gives nullreferenceexception
bool startTimer = false;
double timerIncrementValue;
double startTime;
[SerializeField] double timer = 20;
ExitGames.Client.Photon.Hashtable CustomeValue;
void Start()
{
if (PhotonNetwork.IsMasterClient)
{
CustomeValue = new ExitGames.Client.Photon.Hashtable();
startTime = PhotonNetwork.time;
startTimer = true;
CustomeValue.Add("StartTime", startTime);
PhotonNetwork.CurrentRoom.SetCustomProperties(CustomeValue);
}
else
{
startTime = double.Parse(PhotonNetwork.CurrentRoom.CustomProperties["StartTime"].ToString()); //ERROR LINE******
startTimer = true;
}
}
void Update()
{
if (!startTimer) return;
timerIncrementValue = PhotonNetwork.time - startTime;
if (timerIncrementValue >= timer)
{
//Timer Completed
//Do What Ever You What to Do Here
}
}
Comment
Does the error disappear after the clients have had time to synchronize? Basically you're calling ToString
on null because the property isn't there, or isn't there yet.
Follow this Question
Related Questions
Photon Network instantiate problem when Master changes 0 Answers
Built project, now scripts are missing. 2 Answers
How to network a large map with 4000+ movable objects using Photon Unity Networking? 1 Answer
Instantiate doesn't work with photonView.isMine? 0 Answers
Can I make Money collecting script without attaching it to a object ? I tried but I got error 2 Answers