unity3d - An Object reference is required to access non-static member C# Unity - How do I fix? -
this question has answer here:
i keep getting following error
assets/zoning.cs(12,30): error cs0120: object reference required access non-static member `playercontroller.addfuel(float)'
void ontriggerenter2d(collider2d collider) { if (collider.tag == "player") { debug.log("player re-fueling"); playercontroller.addfuel(1); }
you must create instance of class in order access functions inside it.
playercontroller obj = new playercontroller(); void ontriggerenter2d(collider2d collider) { if (collider.tag == "player") { debug.log("player re-fueling"); obj.addfuel(1); }
Comments
Post a Comment