In the last tutorial, we talked about camera placement and projections. We saw how crucial the position and properties of the camera in order to convey the proper look and feel for your game. Another essential component of this ambiance is the lighting of your scene.

Time is of the utmost importance in almost all video games, be it because it is part of the story itself (like in Majora’s Mask), because you’re required to time your actions very precisely (like in the infamous Dragon’s Lair — considered the first QTE game), because you have limited time to complete a mission (like for some World of Warcraft quests), because you need to wait for something to happen (like in Minecraft, when you want your crops to grow)…

Time might be a simple continuous countdown, or it might match some sort of day and night cycle, as we have in real life.

For example, in MMORPGs where players need to rejoin and play together (and thus share the same “world clock”), the time in-game matches the time in real life and the day-/night-time (based on the server timezone). At the other end of the spectrum, a small game like Tools Up! (2019) relies heavily on time constraints (you have a given amount of minutes to complete the level) but it has absolutely no use for an actual day/night cycle. And so in-between, you have games that have a somewhat realistic day/night cycle mechanism. The Final Fantasy series, Don’t Starve, Starcraft, Sea of Thieves, Minecraft (or the way more recent Valheim)… all have gameplays that incorporate day- and night-time. Depending on the game, the effect of time varies but it almost always has an impact on the rest of the game systems.

In strategy games, it is often used both for storylines and to slightly alter the gameplay so the players stay on their toes.

Our day and night cycle will rely on a set of lights that rotate continuously so that a different light in the set is directed towards the ground depending on the period of the (in-game) day. For now, this cycle won’t have any direct impact on the game other than the lighting of the scene. However in the final game, it might be similar to Warcraft 3’s day/night cycle and:

  • change unit’s health regeneration (both yours and the enemy’s/NPCs’)
  • alter unit’s sight of vision
  • modify the creepers that pop around
  • allow/prevent certain skills from being triggered

Thanks to our event system, it will be fairly easy to hook up the “sun is up” or “sun is down” moments to events emitting and thus catch this specific scene property in our other game systems.

#unity #csharp #games #tutorial

Making a RTS game #11: Adding a day-and-night cycle (Unity/C#)
3.85 GEEK