I am having a few problems with the questing mechanics in my MMO Legends of Earth. So far the GUI and stuff works for the quest but basically. When the player accepts a quest it is supposed to make the AI script attached to the NPC trigger onQuest to true on the Player’s script but it comes up with some weird error saying Assets/Scripts/Questgiver.js(11,32): BCE0020: An instance of type ‘Player’ is required to access non static member ‘onQuest’.
Hello there!
Well. You see your problem is that you need an instance of type ‘Player’ to access the non static member ‘onQuest’.
It means that you’re trying to call the onQuest function of the player without actually having access to the player.
public static Player LocalPlayer;
void Start()
{
LocalPlayer = this;
}
By adding this to your Player script you’ll be able to access the player from anywhere in the game. So now when you want to tirgger onQuest you just use the following line:
Player.LocalPlayer.onQuest();
Oh that solves a lot of problems not only can I sort out the questing I can sort out just about everything.
Thanks