Install Asset
Install via Godot
To maintain one source of truth, Godot Asset Library is just a mirror of the old asset library so you can download directly on Godot via the integrated asset library browser
Quick Information
A 2D βοΈ Day / π Night cycle using CanvasModulate and a moon light effect using Light2D.
Godot 3 2D Day/Night Cycle
A 2D βοΈ Day / π Night cycle using CanvasModulate and a moon light effect using Light2D.
Examples
Cycle without the moon light.
Cycle with the moon light static.
Cycle with the moon light moving.
πΉοΈ Demo
- Clone the repository or download it in a ZIP file.
- Open
day_night_cycle/project.godot. - Play around π.
π Documentation
π οΈ Setup
- Clone the repository or download it in a ZIP file.
- Copy the following files and folders to your project:
Time.gdfile (day_night_cycle/src/Singletons/Time.gd).DayNightCyclefolder (day_night_cycle/src/DayNightCycle).MoonLightfolder (day_night_cycle/src/MoonLight).DebugOverlayfolder (day_night_cycle/src/DebugOverlay).
π Usage
- Prerequisites
- Add a simple cycle
- Add a cycle with a moon light
- Add a delay between cycles
- Add a debug overlay
Prerequisites
Add the Time singleton:
- Go to
Project->Project Settings. - Go to the
AutoLoadtab. - Add the
Time.gdfile. - Enable it.
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
- Create a
CanvasLayerfor the background and set itslayerto-1. - Instance the
DayNightCyclenode in the backgroundCanvasLayerpreviously created. - Instance another
DayNightCyclenode in the root scene and add a delay. - Instance the
MoonLightin the root scene and sync it to theDayNightCyclenode with a delay.
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.
- Create a
CanvasLayerand set itslayerto1. - Instance the
DebugOverlaynode.
Something like this:
Node
βββ TileMap
βββ Player
βββ OtherStuff
βββ DayNightCycle
βββ MoonLight
βββ CanvasLayer (layer = 1)
βββ DebugOverlay
ποΈ Changelog
See CHANGELOG.
π€ Author
hiulit
π€ Contributing
Feel free to:
- Open an issue if you find a bug.
- Create a pull request if you have a new cool feature to add to the project.
- Start a new discussion about a feature request.
π Supporting this project
If you love this project or find it helpful, please consider supporting it through any size donations to help make it better β€οΈ.
If you can't, consider sharing it with the world...
... or giving it a star βοΈ.
π Credits
Thanks to:
- Solo CodeNet - For the YouTube video tutorial that inspired this project.
- Terkwood - For helping with an issue about comparison operators in the cycle state.
- Mitch Curtis - For an amazing PR (#4) that helped improve the project big time.
- Luis Zuno - For creating the Sunny Land assets.
- Twemoji - For the emojis.
- Andrea CalabrΓ³ - For creating the Godot logo.
π Licenses
- Source code: MIT License.
- Emojis: CC BY 4.0
- Godot logo: CC BY 3.0.
- Sunny Land assets: Public domain.
A 2D βοΈ Day / π Night cycle using CanvasModulate and a moon light effect using Light2D.
Reviews
Quick Information
A 2D βοΈ Day / π Night cycle using CanvasModulate and a moon light effect using Light2D.