I'm trying to make a game in which the main character collects something like coins. So, in that main character I have a variable set up to store the number of coins collected. In the Coins class, I am trying to call the method I created in the main character's class to set that variable.
Here's the code in short (main character)
private int Coins=0;
public int getCoins()
{
return Coins;
}
public void setCoins(int num)
{
Coins=Coins+num;
}
and for the Coin class
public Coin()
{
Maincharacter character = (Maincharacter) getOneIntersectingObject(Maincharacter.class)
if (character != null)
{
Maincharacter.setCoins(5);
}
}
Now, when I call try to compile, it tells me that non-static method setCoins(int) cant be referenced from a static context. I'm not really sure whats wrong. I've tried so many different things so I'd appreciate it if y'all could help.

