if i just simply leave it here in the void update it will just scroll my rank up infinatly once i hit the 500 experience points.
(if i remember correctly there is some kind of command, like end, or return or something that would check for it until it happens then stop, but i am not sure what it is and having issues trying to search for it in the doumentation without remembering the keyword. )
or should i put some kind of check like this in another place other then void update?
cool, thank you, would the better ways to do that involve a foreach loop, or coroutine? i haven’t used those too much yet but originally i thought one of those maybe a better way to do it.
int level;
int levelThreshold;
int _experiance;
int experiance {
get {
return _experiance;
}
set {
_experiance = value;
if (_experiance > levelThreshold) {
// level up animation
level++;
levelThreshold += 500;
}
}
}
oh okay, so in order to get the values between scripts i need to put a {get; set;} part into the code for each one i want to get and set the value for in that script?
The get and set methods are called properties. From the outside they are almost identical to fields. But you can do all sorts o interesting things with the data when you receive it.
Some common uses of properties
Data validation
Read or write only data
Triggering an event when data changes
Modifying other data when data changes
Exposing the same data in multiple ways. (Eg exposing the same value of time in terms of hours, minutes, seconds and days)
A couple of things to note about properties that make them different to fields.
Unity doesn’t serialise them, meaning they don’t show up in the inspector
They behave differently to fields under reflection.