Utilizing Time in your code

ElapsedTime()

ElapsedTime is a class that can easily get you the amount of time that has passed since you pressed init() and to the current time step.

Instructions for use:

  1. First create the variable at the top of your code.

ElapsedTime mStateTime;

2. Then create assign it to a new instance of the class.

//Inside Init
mStateTime = new ElapsedTime();

3. Then make sure that it starts when you click the start button

public override void onStart()
{
    mStateTime.startTime();
}

4. Then use it inside your loop using these methods:

  • timeMilliseconds()

  • timeSeconds()

  • timeMinutes()

For Example:

telemetry.addData("Time", mStateTime.timeSeconds().ToString());

Last updated