Hi guys first of all thank you for taking the time to look at this now for my question
I’m trying to create a party system for a rpg im making i have a few scripts to try and accomplish this
for example i have the script BaseCharacter which for example contains
public static string CharactersName { get; set; }
public static int CharactersLevel { get; set; }
then in my script Party.cs i store them in a list
public static List<BaseCharacter> partyMembers = new List<BaseCharacter>();
the variables just wont show up. Is there anyway to access these static vars or maybe a better way to go about this? Thanks in advance and sorry for the noob question
The problem is you are using static wrong. There is no need for static in your example. You are going to work with more than one instance of character, so CharactersName can not be static, and you probably want to have more than one party as well.
Get rid of the static in your BaseCharacter, and then get rid of the static in party.cs then you will have a working party with party members that can be configured through the editor.
If you just write
public string CharactersName;
instead of using a property it is better in this case because you can directly edit the value of CharactersName within the editor.
The name ‘CharactersName’ is bad style when used within a class BaseCharacter because the class name indicates this is a character.
class CharacterBase : MonoBehaviour
{
public name;
public level;
public xp;
// add further attributes here or in derived classes
}
public Party : MonoBehaviour
{
public List<CharacterBase> characters;
}
This code can now be directly attached to gameObjects and your party list can be populated within the editor ( or from script only if you prefer )