0

I'm trying to make a simple console application and don't want to use Unity, but I want to implement a timer, so I would want to use Time.deltaTime.

DMGregory
  • 134,153
  • 22
  • 242
  • 357
  • Time.deltaTime is a Unity specific thing. If you want one in console application you can use a 3rd party lib or write your own. Time.deltaTime is calculated as time between frames, so if there are no frames and Unity engine is not running - the value probably won't be calculated. That is my assumption. Even if the value would be calculated it would be completely irrelevant value to console application. – Candid Moon _Max_ Jul 02 '22 at 11:09
  • Are you asking how to program a [tag:game-loop] and measure the time elapsed per frame? What have you tried, based on your research of existing guides and Q&A so far? – DMGregory Jul 02 '22 at 11:38

1 Answers1

0

How to Measure deltaTime

It is measured by calling a timer every frame per second that holds the time between now and last call in milliseconds. Thereafter the resulting number (delta time) is used to calculate how far, for instance, a video game character would have travelled during that time.

Basic implementation in Javascript

let lastTime = performance.now(); // performance.now() returns the current timestamp
function gameLoop() {
    let now = performance.now();
    let deltaTime = now - lastTime;
    lastTime = now;
}
SCodes
  • 3
  • 3