- Home /
Casting Object to a Bool ready check
Getting an error with the following bit of code, trying to create a ready check in Photon so that all players load the next scene at the same time, I am using the custom player properties from photon to achieve this and I believe this is where the error is coming.
Cannot implicitly convert type 'object' to 'bool'. An explicit conversion exists (are you missing a cast?) Assembly-CSharp
Code that is throwing the error
private bool AllPlayersReady()
{
return PhotonNetwork.PlayerList.All(player => player.CustomProperties["PlayerReady"]);
}
It is probably something very simple just a bit unsure as to how to solve it
Answer by TreyH · Dec 27, 2019 at 04:01 PM
This should be all you need:
private bool AllPlayersReady()
{
return PhotonNetwork.PlayerList.All(player => (bool)player.CustomProperties["PlayerReady"]);
}
Your answer
Follow this Question
Related Questions
Custom Properties, Unity, Object refence not set to an instance of an object 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Unity Photon Ready check 0 Answers
How do i change the GUI.Box font size and box size ? 0 Answers