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

No idea what im doing

Discussion in 'Scripting' started by Bec1991, Jul 8, 2020.

  1. Bec1991

    Bec1991

    Joined:
    Jul 6, 2020
    Posts:
    2
    Hey, I've just started coding and I have no idea why this is wrong or how to execute what I'm trying to do.
    I'm trying to add 2 to my skill levels when my player levels up.
    my code is
    void LevelUp()
    {
    currentXP = 0;
    playerLevel += 1;
    print("CONGRATULATIONS! YOU LEVELED UP");

    if(playerLevel =>1)
    {
    quiverLevel + 2;
    strengthLevel + 2;
    skillLevel + 2;
    }
    }

    I know this is wrong but have no idea how to fix it
     
  2. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    You can either do

    skillLevel = skillLevel + 2;

    Or

    skillLevel += 2;
     
    Bec1991 likes this.
  3. Bec1991

    Bec1991

    Joined:
    Jul 6, 2020
    Posts:
    2
    int currentXP = 0;
    int xpThreshold = 100;
    int playerLevel = 0;
    int strengthLevel = 0;
    int quiverLevel = 0;
    int skillLevel = 0;
    int highXP = 200;
    int mediumXP = 100;
    int lowXP = 50;

    void LevelUp()
    {
    currentXP = 0;
    playerLevel += 1;
    print("CONGRATULATIONS! YOU LEVELED UP");
    xpThreshold = xpThreshold * 2;

    if(playerLevel =>1)
    {
    quiverLevel = quiverLevel + 2;
    strengthLevel = strengthLevel + 2;
    skillLevel = skillLevel + 2;
    }
    }

    now im getting an error message of
    error CS1660: Cannot convert lambda expression to type 'bool' because it is not a delegate type
     
  4. Yanne065

    Yanne065

    Joined:
    Feb 24, 2018
    Posts:
    175
    if(playerLevel =>1)

    Change to


    if(playerLevel >=1)