Skip to main content

011. Unity3d Tutorial - Character Statistics 1/7

See video

In this tutorial, we will create the BaseStat class that we will use to later create our Attribute, Vital, and Skill classes.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Offline
Joined: Jan 29 2011

Hey i downloadedd your scripts and when i go to put them into the game it says cant add script. The script needs to derive from monobehaviour

Petey's picture
Offline
Joined: Feb 3 2010

I did not make this demo, but there is a link to the code in the description. This was found on YouTube, and I thought it was cooll so I added it.

Off the top of my head, when the player wants to enter a vehicle, I would have the mesh for the player vanish, and then have the mesh for the vehicle become my new mesh.

Offline
Joined: Jan 29 2011

wait so how do you get this to work sense i have the scripts i bought from you and it wont let me add them to anything any object or anything and it doesnt show up so what do i have to do to make what you show at the beginning of this video work in my game???

Offline
Joined: Jan 6 2012

It is not meant to be attached to any object in game.

Offline
Joined: Mar 25 2011

Assets/Scripts/Character Classes/NewBehaviourScript.cs(7,16): error CS1519: Unexpected symbol `public' in class, struct, or interface member declaration

Please, can you tell me whats is the error?

public class BaseStat {
private int _baseValue; //the bae valie of this stat
private int _buffValue; //the amount of th buff to this stat
private int _expToLevel; //the total amount of exp needed to raise this skill
private float _levelModifier //the modifier applied to the exp needed to raise the skill

public BaseStat() {
_baseValue = 0;
_buffValue = 0;
_levelModifier = 1.1f;
_expToLevel = 100;
}

//Basic Setters and Getters
public int BaseValue {
get{ return _baseValue; }
set{ _baseValue = value; }
}

private int BuffValue {
get{ return _buffValue; }
set{ _buffValue = value; }
}

private int ExpToLevel {
get{ return _expToLevel; }
set{ _expToLevel = value; }
}

private float LevelModifier {
get{ return _levelModifier; }
set{ _levelModifier = value; }
}

private int CalculateExpToLevel() {
return (int)(_expToLevel * _levelModifier);

}

public void LevelUp() {
_expToLevel = CalculateExpToLevel ();
_baseValue++;
}

public int AdjustedValue() {
return _baseValue + _buffValue

; }
}

Offline
Joined: May 29 2011

You forgot your cast between the arrows :-)

public class BaseStat {
private int _baseValue; //the bae valie of this stat
private int _buffValue; //the amount of th buff to this stat
private int _expToLevel; //the total amount of exp needed to raise this skill
private float _levelModifier >>>>>> ; <<<<<<< //the modifier applied to the exp needed to raise the skill

Offline
Joined: May 11 2011

Umm how r u using floats and integers together like that... because usually you cant multiply at INT by a FLOAT i get errors stating "Error 1 Cannot implicitly convert type 'float' to 'int'. An explicit conversion exists (are you missing a cast?)"

Offline
Joined: Aug 11 2011

check out the next vid for your fix.

Offline
Joined: Oct 30 2011

I'm trying to use exptolevel=exptolevel(expancetolevel+1)/2 for the experience to level modifier. So if I were using single digits it would be 1,3,6,10,15,21 ect... But I don't know how to represent that in C# and guidance or suggestion will be helpful and thank you in advance