Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  1. Basics
  2. Engine Systems
  3. Core Systems

Day Time Controller

PreviousScenes LoaderNextWeather Controller

Last updated 4 months ago

Presented by IDayTimeController interface, this system allows to simulate switching between day and night.

To use it, just add DayTimeController prefab onto your game scene and set it up as you wish.

Parameters in inspector

Sun – reference to Light source which will be moved

Day Length – length of day in seconds

Night Length - length of night in seconds

Time Of Day – initial time of day (from 0 to 1, where 0 is sunrise, 0.5 is sunset and 1 is sunrise again).


You can also set current time of day via code. For this, you need to inject this system to needed class and call SetTimeOfDay method, like shown below:

[Inject] private IDayTimeController dayTimeController;

private void ExampleMethod()
{
    // 0 is sunrise
    dayTimeController.SetTimeOfDay(0f);
    
    // 1 is sunrise too
    dayTimeController.SetTimeOfDay(1f);

    // 0.5 is sunset
    dayTimeController.SetTimeOfDay(0.5f);
}

You should pass number from 0 to 1 as parameter, where 0 is sunrise, 0.5 is sunset and 1 is sunrise again. It's easier to understand with this simple diagram:


You can see how it works on the WeatherTestScene, which is situated in Assets/Heroic Engine/Example/Scenes directory.

Sun movement diagram
DayTimeController prefab
Parameters in inspector
Drawing