- Home /
How to add points when a curtain score is reached ?
I need to add point every time the player reaches a score.
if the score is over 1000, give 1 point. If the score is over 3000, give 2 additional points, so it becomes 3 points in total. From what I've read it its best to use the % operator but I cant make it work.
Comment
Answer by melsy · Aug 13, 2017 at 06:33 PM
I create a default value for the points, then create interval at which to compare to.
int playerPoints; int defaultValue = 1000; int interval; int coins;
private void Start()
{
interval = defaultValue;
}
private void Update()
{
if(playerPoints > interval)
{
coins++;
interval += defaultValue;
}
}
You can also multiply it to increment automatically
int playerPoints;
float defaultValue = 1.5f;
int interval = 1000;
int coins;
private void Update()
{
if(playerPoints > interval)
{
coins++;
interval *= defaultValue;
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to multiply two vector4 3 Answers
Save points from one scene to another? 3 Answers