CS0120 An object reference is required for the non-static field, method, or property 'HomeController._accessor' code example
Example 1: CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState'
public class Upgrader1 : MonoBehaviour
{
PlayerController PlayerController;
void Start()
{
GameObject Player = GameObject.Find("Player");
PlayerController = Player.GetComponent<PlayerController>();
}
public void Upgrade1()
{
PlayerController.speed++;
}
}
Example 2: CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState'
PlayerController obj = new PlayerController();
void OnTriggerEnter2D(Collider2D collider) {
if (collider.tag == "Player")
{
Debug.Log("Player is Re-Fueling");
obj.AddFuel(1);
}