I decided to implement a public
Getter. In PlayerController.cs
I implemented the following at the top of the script:
{
get { return _canMove; }
}
private bool _canMove = true;
Then where you need to check it, you add a tiny bit of extra code:
if (other.gameObject.CompareTag("Ground") && FindObjectOfType<PlayerController>().CanMove)
{
//Do crash-related stuff here
}
Having a private bool
variable protects against accidentally setting it from outside the PlayerController
class, while only having to manage one state and the public
Getter let’s me read the bool
wherever I want.
Not entirely sure it’s the cleanest/best solution but I did enjoy the challenge of working it out.