Answers for "CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState'"

C#
0

CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState'

public class Upgrader1 : MonoBehaviour
{

PlayerController PlayerController; //It should be member variable

void Start()
{
    GameObject Player = GameObject.Find("Player");
    PlayerController = Player.GetComponent<PlayerController>();
}

public void Upgrade1()
{
    PlayerController.speed++;
}
}
Posted by: Guest on March-29-2021
0

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);
     }
Posted by: Guest on March-29-2021

Code answers related to "CS0120: An object reference is required for the non-static field, method, or property 'PlayerControls.currentState'"

C# Answers by Framework

Browse Popular Code Answers by Language