I am counting score with a deltaTime timer and want to save the end value as an int. ,I want to count score with delta.Time timer. Is it possible to save a “running” int?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ScoreCounter : MonoBehaviour
{
public Text currentScore;
private float secondsCount;
public int finalScore = 0;
public GameObject obstacleSpawner;
void Update()
{
if (obstacleSpawner.GetComponent<ObstacleSpawner>().mängAlgas == true)
{
ScoreWithTime();
if (GetComponent<TreeBehavior>().mängLäbi == true)
{
finalScore = //hmmm
}
}
}
//call this on update
public void ScoreWithTime()
{
//set timer UI
secondsCount += Time.deltaTime;
currentScore.text = "" + (int)secondsCount * 10;
}
}
//if (secondsCount >= 60)
//{
// print("aeg täis");
// obstacleSpawner.GetComponent<ObstacleSpawner>().round2 = true;