In this script you can see how time goes up from 0 (using Time.deltaTime).
In my case,i want that unity prints massage for me when time is exactly 35 (FirstPass)
Function works if time is greater than or less than Firstpass,or second or third.
But when i want that time is exactly equals to FirstPass,which is 35…the massage is not showing…
By the way it works only when i disable time counting up and enter the value manually…
Why? Please.
#pragma strict
var time : float = 0.0f;
var FirstPass : float = 35.0f;
var SecondPass : float = 45.0f;
var ThirdPass : float = 55.0f;
var SpeedOfTime : float;
function Update ()
{
//if(Input.GetKeyDown(KeyCode.Space))
TimeStarts();
time += Time.deltaTime * SpeedOfTime;
}
function TimeStarts ()
{
if(time == FirstPass)
{
print("FirstPass");
}
if(time > SecondPass)
{
print("SecondPass");
}
else if (time == ThirdPass)
{
print("ThirdPass");
}
}