I am trying to be able to change a bool value from multiple scripts, but when I tried it made things stop working. A quick breakdown, I have a PlayerController script which controls the movement of the player, and also has a bool called “canMove”, and must be true for the player to be able to be moved.
In a TextBoxManager script I have called the PlayerController script with
“public PlayerController ness;”
then in Start() “ness = FindObjectOfType();”
and when a textbox is enabled
“canMove = false;”.
This worked fine, until I created a new script MenuController and tried calling the PlayerController script the exact same way, and would make “canMove = false” whenever the key to bring up the menu was pushed down.
Now my character is unresponsive to player input when the menu is called, but when talking to a NPC and the dialogue box appears, the player is freely able to move around (the TextBoxDialouge script is not setting “canMove = false” anymore). Is this not allowed in C# to call the FindObjectOfType in multiple scripts?? Or should I be referencing the script in another way? I eventually want the dialogue box and menu to be in the same graphic, but baby steps, I’m still very new to game design and programming.