StackOverflowException: The requested operation caused a stack overflow.

i have an error i dont know what its means if someone could help me please

1844383–118303–TestGUI.cs (705 Bytes)

You haven’t given us nearly enough information. You need to give us the stack trace that shows what line the error happened on and where it happened. If the error is happening “in this script” though, my guess is that it’s not actually in this script because I don’t see anything that would cause it. My guess is that it would be something in the constructor of one of your other two classes (BaseMage or BaseWarrior) but without seeing the stack trace and correct code there’s no way to help you.

so should i send you the warrior class and mage ?

no, just which line tells you the console that is causing the stack overflow

BaseCharacterClass.set_CharacterClassName (System.String value) (at Assets/Scripts/Character Classes/BaseCharacterClass.cs:18)

its to do with BaseCharacterClass i think

we need to see the line 18 of the BaseCharacterClass then

i have to upload the script

1844873–118335–BaseCharacterClass.cs (834 Bytes)

  public string CharacterClassName
{
     get{ return CharacterClassName;}
     set{ CharacterClassName = value;}
    }

there you are doing a recursive assign, you are assigning value to CharacterClassName which then does the same thing, you should have characterClassName=value instead

EDIT: either that, or just

public string CharacterClassName
{
     get;
     set;
}

…and also, you wrote staminia instead of stamina

thank you im new to this so i didnt know

  • public string CharacterClassName
  • {
  • get;
  • set;
  • }

worked 100% :slight_smile: Thank you

if you could help me with this error please Assets/Scripts/Items/CreateNewWeapon.cs(19,19): error CS0029: Cannot implicitly convert type int' to string’ i would be so thankful

Heres the script

1844894–118336–CreateNewWeapon.cs (1.4 KB)

line 19 please

nvm, newWeapon.ItemID = Random.Range(1,101); itemID seems to be of type string, and Random.Range returns an integer, so… modify the itemID as an int

Thank you