In my game there is a game manager that interacts with all players and is able to change whether a player is actionable by accessing their script. However, the Game manager script simply refused to change the actionable bool. There were no errors produced either. Even changing all of the private variables to public didn't change anything. What am I doing wrong?
My player script:
public class PlayerManager : MonoBehaviour
{
public bool actionable;
void Start()
{
actionable = false;
}
}
My Game Manager Script:
public class GameManager : MonoBehaviour
{
private PlayerManager playerScript;
public List<GameObject> players = new List<GameObject>();
private GameObject currentPlayer, seats;
private int turn;
void Start()
{
turn = 0;
currentPlayer = players[turn];
playerScript = currentPlayer.GetComponent<PlayerManager>();
playerScript.actionable = true;
}
}
actionable
in theirStart
method. Is it possible that the player'sStart
is running after the game manager'sStart
, and overwriting the value that it set? Did you consider moving the player's initialization toAwake
or using Script Execution Order settings to ensure the game manager gets the last word here? \$\endgroup\$actionable
in theGameManager
right away to false and not inStart
as well. \$\endgroup\$