Pierre Angelo

Generation

generate functionWed, 05 Apr 2023

¿Cómo mostrar por pantalla el tiempo transcurrido en unity?

void tiempo(){ const int numFrames = 100; float deltaTime[numFrames]; int frameIndex = 0; float frameTime = 0.0f; float lastTime = 0.0f; float fps = 0.0f; for (int i = 0; i < numFrames; i++) { //Tiempo actual del frame float startTime = Time.realtimeSinceStartup; //Tiempo del ultimo frame deltaTime[frameIndex++] = startTime - lastTime; //Si el frameIndex llega al limite vuelve al comienzo if (frameIndex >= numFrames) frameIndex = 0; //Guarda el tiempo del ultimo frame lastTime = startTime; float count = 0; for (int j = 0; j < numFrames; j++) count += deltaTime[j]; //calculo del tiempo de los ultimos frames frameTime = count/num

Questions about programming?Chat with your personal AI assistant