- Home /
How to increment a value for every point put into another value?
Ok the concept is simple, I have a value called Damage, I have a stat system, STR, INT, etc.. What I want to do is increase Damage by say +5 for every point I put into STR how would, I do this. I've tried to google search the answer, i couldn't find anything, wether it be because there is no answer or I didn't know what to type to find it. Any help is very much appreciated.
Answer by Llama_w_2Ls · May 13, 2021 at 04:34 PM
Use properties and get; set; accessors. These allow you to call events whenever a value is retrieved or set from anywhere in the code. Here's an example:
public int Damage;
int _myothervalue = 0;
public int MyOtherValue
{
get { return _myothervalue; }
set
{
_myothervalue = value;
// Will increment damage whenever this value is set
Damage++;
}
}
Answer by Ytsorf · May 13, 2021 at 12:37 PM
Hi there, I'm not sure im following your question, try to post the code. Also I think with an If() could solve that question
Your answer
Follow this Question
Related Questions
Input.GetKey(KeyCode.E) Not Working 1 Answer
Apply Perlin Noise to a Sphere 1 Answer
TCG to not be able to see the other players hand 1 Answer
Unhandled Exception. We Hate Them, But They Happen 0 Answers
If statement with OnGUI 2 Answers