This repository contains the completed code for my Godot 4 Day-Night Cycle tutorial. This system provides a super simple day and night cycle that can enhance the atmosphere and gameplay of your projects.
- Smooth transition between day and night states
- Directional light that simulates sun movement
- Time-based lighting system
- Customizable cycle duration
- Animation player for smooth sun arc movement
- Easy integration with existing projects
- Performance optimized implementation
- Clone or download this repository
- Open the project in Godot 4.x
- Run the title scene to see the day-night system in action
- Explore the code to understand how it works
- Copy the directional light setup from the demo scene
- Add the Animation Player with sun rotation animation
- Include the cycle controller script
- Customize cycle timing and lighting properties
The system could easily be extended with:
- Weather effects tied to time of day
- Different lighting for different biomes or areas
- Gameplay mechanics that change with time of day
- Moon lighting for night time
- NPC schedules based on time of day
Scenes/title.tscn- Example title screenScenes/demo_level.tscn- First example level with day-night cycle (where the day-night cycle is)Scenes/player.tscn- Player character
The system uses a DirectionalLight node to simulate the sun, with an AnimationPlayer to control its rotation throughout the day. The lighting properties (color, intensity, shadow parameters) are adjusted based on the time of day to create realistic dawn, day, dusk, and night effects.
This project is licensed under the MIT License - see the LICENSE file for details.
Thank you for downloading this simple little day-night cycle demo. I hope it helps improve the immersion and atmosphere in your games, or at least gets you started. If you have any questions or issues, create an issue in this repo or comment on one of my videos.