I have a game that calculates your score via Time.deltaTime
(the more time the more score). On my PC I get about 1200 points if I just idle the game while on my phone I only get about 400 points.
I believe my code must be FPS dependant and that's why my phone is getting a lower score for the same time.
Here's the code:
void Update ()
{
time += Time.deltaTime;
score += (int)time;
timerLabel.text = score.ToString();
}
Sorry if it's something very obvious. I'm quite new at c#.
Can't seem to get the solution to work. It just stays at 0:
Full Code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
public class EndGame : MonoBehaviour {
public Text textWin;
public Text timerLabel;
public GameObject retryButton;
public GameObject points;
private Vector3 offset;
private float time;
private float score;
void OnTriggerEnter (Collider col) {
if (col.gameObject.name == "Player") {
setWinText ();
retryButton.SetActive (true);
points.SetActive (false);
}
}
void setWinText () {
textWin.text = "Final score: " + score.ToString();
}
void Update ()
{
time += Time.deltaTime;
if (time >= 1.0f) {
++score;
score -= 1.0f;
}
timerLabel.text = score.ToString();
}
}