Hello I am working on a game, can anyone tell me how to calculate the score based on seconds?
For instance if the player plays for 10 seconds the score will be 10; 1 second = 1 point;
var startTime: float;
function GameStarts()
{
startTime=Time.time;
}
function CalculateScore(): int
{
return ( Time.time - startTime);
}
Because time is granular , if you wanted to do you could multiple the result by 10 and have a score that has fractions of a second.
It displays mili-second because u have assigned the score avriable as float.
var score : int;
now the scoring will in fixed value
what you can also do is :
var score : int
function Start()
{
score = 0;
}
function Update()
{
score = Time.timeSinceLevelLoad;
Debug.Log("score");
}