Drop timer challenge in obstacle course lesson

Sharing my attempt -
updating the debug log until we reach our timer goal (3 seconds) and then suspending it.

added a RigidBody variable to adjust the gravity - not strictly needed but good practice?

Since this is also an object the player can “hit” I added a compare tag for the obstacle hit script to turn red if the thing that hit us was the player. (Dropping it onto the ground also creates a collision and we don’t want that to trigger a red color change). Also edited the player tag to Player …

Attached both my DropObstacle Script and the the ObjectHit script to the dropper cube.

my “ask” is the comments I left myself near the top of the drop obstacle script - making this generic, is timer the right way to go? Does Time.time get reset if we add pause to our game? Thanks! I’m enjoying the course!

It’ll depend on how you pause the game. If you do it through Time.timeScale = 0f; then Time.time will pause along with the rest of the game. If you put Time.timeScale to 0.5f, Time.time will progress at half speed.

If you’re looking for time that isn’t altered by pausing, try using Time.realtimeSinceStartup.

Whether it’s the right way depends on what you’re trying to accomplish. If you want the timer to pause, then you’re all good. If you want it to only consider real time, then it’s not as good.

thanks!

Did Michael’s answer help?


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms