Hey guys,
tl;dr: delta time change returning 0, based off System.nanoTime()
So recently I’ve been dabbling in creating a large voxel engine based game however i had my game running nicely for testing added features and what not however my clock timer randomly stopped working, and i cannot figure it out for the life of me.
Here is my main issue when i run to get delta in the game for movement gravity etc i call the getDt() method and use that for delta and at the beginning of my game loop i call the updateTimeChange() method however the delta returns 0 for every cycle.
Any pointers on how to correct this?
public class Clock {
private static float time;
private static float lastTime;
private static float dt;
public void updateTimeChange(){
time = System.nanoTime();
dt = (time - lastTime)/ 1000000;
lastTime = time;
}
public float getDt(){
return dt;
}
public Clock(){
lastTime=System.nanoTime();
}
}