Ivan_a
1
This may sound like a silly question and it may well be i have been behind the screen for too long.
How do i create an if statement which checks if score is adding.
if(score has added one point)
{
run this once;
}
else if (score has subtracted)
{
run this once;
}
You’re going to need to keep track of the previous score somewhere.
private int _previousScore;
private int _currentScore;
void Start() {
this._previousScore = 0;
this._currentScore = this._previousScore;
}
//amount can be negative for subtracting points
void ChangeScore(int amount) {
this._previousScore = this._currentScore;
this._currentScore += amount;
}
void Update() {
if (this._previousScore > this._currentScore) {
//score subtracted points
}
else if (this._previousScore < this._currentScore) {
//score added points
}
else {
//score was not changed
}
}