Original author: @uheartbeast
- Godot 4+ support
- Better exports for editor
- Debounce
- Optimizations (re-render only when it really needs and cache things)
- Character following example
The repo itself is a ready to use Godot project.
Just download it and import as new project.
Simple character with script for movement is included.
- Select your main scene Node2D object
- Attach script to it
- Copy code from game.gd and paste it to your editor
- Create "light" texture. See example: Light.png
- Edit code as you want
- Add Sprite2D to scene. This will be your fog
- Disable "Centered" property under
Offset
tab on your fog object - Select fog object, open
Material
, click new CanvasItemMaterial. Click on it, setBlend mode
property toMultiply
By default, it requires CharacterBody2D object.
Check _process
and _input
functions if you want to adapt the code for your project.
_process
function is using a .get_input()
method which is declared in player.gd example.