mikolo
August 19, 2010, 8:02pm
1
Hello,
i`ve following Math question in following code:
private var runnig_time : int = 5;
private var now_time : int;
private var next_time : int;
function Start(){
next_time = Time.time + runnig_time;
}
function Update() {
now_time = Time.time;
if (now_time > next_time) {
print("-----END TIME-----");
}
}
This works perfectly, now i want to show the percent value between now_time and next_time?
I want to scale a loading bar(GUI Texture) from 100 percent down to 0 percent in this code. Can somebody help me please?
vastor
August 20, 2010, 8:59am
2
current percent value:
var percent = 100 / next_time * now_time;
mikolo
August 20, 2010, 9:41am
3
function startRecordingJokerTime() {
now_time = Time.time;
var seconds_down : float = next_time-now_time;
//print("-----seconds_down-----"+seconds_down);
//print("-----now_time-----"+now_time);
var percent = 100 / next_time * now_time;
print("-----percent-----"+percent);
//if (now_time > next_time) {
//oder
if (seconds_down == 0) {
//print("-----ENDE JOKER-----");
attack_ninja = false;
}
}
startRecordingJokerTime is called in the update function and stops if attack_ninja = false.
But the print result starts not from 0 to 100 continuely? For example it starts by 28, the it stays a while and the next value is 42 ??? Is it possible to calculate from 100 to 0 continuely while the function is called? Thanx for reply
vastor
August 23, 2010, 1:23pm
4
your code does not look wrong can u give more information when u call startRecordingJokerTime() ?