Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

need help with setting up exp

Discussion in 'Scripting' started by shadowgamer24, Oct 22, 2020.

  1. shadowgamer24

    shadowgamer24

    Joined:
    Jun 26, 2020
    Posts:
    5
    the bold part is what I need help with. I want to increase the level by 1 when they reach the exp requirement the error code is
    Assets\scripts\exp.cs(21,13): error CS0149: Method name expected

    public class exp : MonoBehaviour
    {
    public int NextLevel = 100;
    public int Curentlevel = 0;
    public int currentExp { get; private set; }
    // Start is called before the first frame update
    void Start()
    {
    currentExp = 0;
    }


    public void level(int LevelUp)
    {
    if (currentExp >= NextLevel)
    {
    LevelUp();
    }
    }

    public void ExpGained(int exp)
    {
    currentExp += exp;
    }

    public void LevelUp()
    {
    Curentlevel += 1;

    }
    }
     
  2. Sphinks

    Sphinks

    Joined:
    Apr 6, 2019
    Posts:
    267
    You named your parameter with the same name like your method:
    public void level(int LevelUp)


    change the starting letter to a small l
     
  3. shadowgamer24

    shadowgamer24

    Joined:
    Jun 26, 2020
    Posts:
    5
    thx it working now