How would I Increment by X per second...
I know how to increment per second but how would I increment by more then one and add it seperately say add one every...0.3 seconds?
How would I Increment by X per second...
I know how to increment per second but how would I increment by more then one and add it seperately say add one every...0.3 seconds?
var incrementTime = .3;
var incrementBy = 1;
private var counter = 0;
function Start () {
InvokeRepeating("Increment", incrementTime, incrementTime);
}
function Increment () {
counter += incrementBy;
}
You could use Time.deltaTime , too. This C# code is stripped down to the essentials.
float incrementTime = 0.3f;
float incrementBy = 1;
float counter = 0;
double time =0;
public void Update()
{
time+=Time.deltaTime;
while(time>incrementTime)
{
time-=incrementTime;
counter+=incrementBy;
}
}
#pragma strict
function Start () {
}
private var pauza_sec :float= 0;
private var urm_nr:int = 0;
private var start_timp:int = 0;
private var final_timp:int =10;
function Update ()
{
if (start_timp< final_timp)
{
urm_nr= (Time.time) + pauza_sec; //+ un nr. si neaparat time.time + ceva(numar obligatoriu)
print(urm_nr);
}
}