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;
}
}
actionablein theirStartmethod. Is it possible that the player'sStartis running after the game manager'sStart, and overwriting the value that it set? Did you consider moving the player's initialization toAwakeor using Script Execution Order settings to ensure the game manager gets the last word here? \$\endgroup\$actionablein theGameManagerright away to false and not inStartas well. \$\endgroup\$