Wednesday, September 30, 2015

Day 38: Plenty Done in Real Time

Today was a day to get a couple of tweaks done on the game, and I definitely ran into a few challenges on these so-called "simple" tweaks. The main part of this challenge came from the integration of a pause menu with the computer-time based timers I had implemented for scenes and sounds, unlike the deltaTime which the pause function relied on. For the pause, it sets timeScale to 0, effectively stopping all things that rely on deltaTime. However, the timer continues forward (since we're constantly comparing it to DateTime.Now. What was the solution? Save the time elapsed on pause (since it was overall instead of repeating every timer call, I had to use a modulo operator) and reset the timer with that elapsed time as an offset.

This especially came in handy when incorporating an oxygen timer on top of the oxygen bar when the meter was low, showing exactly how many seconds you had left. It just baffles me to see how little Unity takes into account timers that use actual time.

No comments:

Post a Comment