Hello. Sorry for that simple question, but I am new to C# and I want to ask: how can I access a variable of a class and modify it in other class. For example:
public class PlayerMovement : MonoBehaviour
{
public bool IsPlayerOnGround;
void Start ()
{
IsPlayerOnGround = false;
}
void Update()
}
public class GroundCheck : MonoBehaviour
{
//I need to access and modify "IsPlayerOnGround" in this class,
//so that it would be changed in PlayerMovement class
}
What I don’t get, is that you don’t need to create PlayerMovement player = new PlayerMovement() or something in Unity, so I don’t know how to change it access it. Can someone explain, why I do not to create an object of the class to put it to Update() and Start() functions and why it works? Thanks!
Thank you a lot, smoggach. Your answer really helped me to understand these important basics of Unity and solve my problem. Thanks :)
– DainiusssYou are really wonderful man. Thanks you a lot)
– dom_cobb_22