Home

Awesome

Godot 3 2D Day/Night Cycle

Godot v3.x GitHub release (latest by date) GitHub license

A 2D β˜€οΈ Day / πŸŒ” Night cycle using CanvasModulate and a moon light effect using Light2D.

Godot 3 2D Day/Night Cycle Banner

Examples

Cycle without the moon light

Cycle without the moon light.

Cycle with the moon light static

Cycle with the moon light static.

Cycle with the moon light moving

Cycle with the moon light moving.

πŸ•ΉοΈ Demo

πŸ“‘ Documentation

πŸ› οΈ Setup

πŸš€ Usage

Prerequisites

Add the Time singleton:

Enable the time.gd singleton

Change the Time parameters to your liking.

Add a simple cycle

Instance the DayNightCycle node in the root scene.

Node
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
└── DayNightCycle

Change the DayNightCycle parameters to your liking.

Add a cycle with a moon light

Instance the DayNightCycle node and the MoonLight node in the root scene.

Node
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
β”œβ”€β”€ DayNightCycle
└── MoonLight

Sync the MoonLight with the DayNightCycle.

The MoonLight can be static or moving in sync with a DayNightCycle.

Change the DayNightCycle parameters and the MoonLight parameters to your liking.

Add a delay between cycles

Something like this:

Node
β”œβ”€β”€ CanvasLayer (layer = -1)
β”‚   └── BackgroundSprite
β”‚   └── DayNightCycleBackground (delay = 0)
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
└── DayNightCycleForeground (delay = 1800)
└── MoonLight (cycle_sync_node_path = DayNightCycleForeground)

This will create the effect that the background starts changing before the foreground.

Add a debug overlay

Test the passing of time, the cycles and the moon light.

Debugg overlay example

Something like this:

Node
β”œβ”€β”€ TileMap
β”œβ”€β”€ Player
β”œβ”€β”€ OtherStuff
β”œβ”€β”€ DayNightCycle
β”œβ”€β”€ MoonLight
└── CanvasLayer (layer = 1)
    └── DebugOverlay

πŸ—’οΈ Changelog

See CHANGELOG.

πŸ‘€ Author

🀝 Contributing

Feel free to:

πŸ™Œ Supporting this project

If you find this project helpful, please consider supporting it through any size donations to help make it better.

Become a patron

Suppor me on Ko-Fi

Buy me a coffee

Donate Paypal

If you can't, consider sharing it with the world...

... or giving it a star.

πŸ‘ Credits

Thanks to:

πŸ“ Licenses