- Home /
Time and float?
My script calculates the difference between two dates and i get a TimeSpan:
var difference : TimeSpan = currentDate.Subtract(oldDate);
My script products 1 unit in every minute. How can i multiply the units by the time difference?
I hope you can understand me
I have no idea what you talk about... sorry :|
Difference between what times? What does the difference represent? How long it takes to produce one unit?
If you want a time value like Time.time you might want to use
However it will return a double ins$$anonymous$$d of a float
Answer by Nevak · Mar 28, 2014 at 06:10 PM
I don't know if I understood your question correctly but if you want to repeat a certain action every "X" seconds you could use InvokeRepeating which is really easy to use:
function Start() {
// A unit will be produced every 60 seconds
// The "0" in the 2nd argument is the delay to start producing. So 0 seconds i.e. start producing now
InvokeRepeating("ProduceUnit", 0, 60);
}
function ProduceUnit() {
// Your unit instantiation code would be here...
}
You can have a look at the docs aswell:
http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.InvokeRepeating.html
Your answer
Follow this Question
Related Questions
Do if after date. 2 Answers
WebGL - Get "host"/"server" time and date? 2 Answers
In game clock/Time 1 Answer
difference with Time.time, Time.deltatime, Time.frameCount 3 Answers
Access the system time on mobile 1 Answer