- Home /
Question by
stephen_george98 · Apr 22, 2016 at 05:39 PM ·
uitimescorescore systemmultiply
Score Multiplier by Time
Here is my score manager script I made:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScoreManager : MonoBehaviour {
public Text scoreText;
public float scoreCount; // What the score is when the scene first loads. I set this as zero.
public float pointsPerSecond; // Every second, the points increase by THIS amount. Right now it is 100.
// Update is called once per frame
void Update () {
scoreCount += pointsPerSecond * Time.deltaTime;
scoreText.text = "" + Mathf.Round (scoreCount); // It comes out as a float with like 6 decimals; I round to an nice, clean Integer
}
}
My problem that I cannot figure out how to solve is: How do I make a multiplier that increases the score by times 2 after 30 seconds of the game, then increases the score by times 3 after 1 minute, then times 4 after 1 Minute and 30 seconds, then finally, times 5 after 2 minutes? Thanks
Comment
Do you want it to time by 3 after a $$anonymous$$ute or do you want it to be 3 times the original value?
Answer by MakakWasTaken · Apr 22, 2016 at 05:43 PM
You could do something like this
private float scoreMultiplier = 1.0f;
private void Update()
{
if (Time.timeSinceLevelLoad - lastTime >= 1.0f)
{
lastTime = Time.timeSinceLevelLoad;
scoreMultiplier += Time.deltaTime / 30.0f;
scoreCount += pointsPerSecond * scoreMultiplier;
}
}