Search code examples
godotgodot4

I can not create a Light2d in Godot 4. What should I do?


I want to create a light2d in Godot4. But the button of the Light2d is gray.So I can’t create it. But I can create the Point Light2d What should I do?

In addition,the system I use is Windows10.I run the Godot4 with steam.

I try to click the button. I also change the mode and restart the Godot. But it didn’t work.


Solution

  • Light2D is a base class that cannot be used directly. Instead you need to use one of the inheriting classes. In this case, this means that you can use a DirectionalLight2D or a PointLight2D.

    Which one you should use depends on your use case, but generally:

    • DirectionalLight2D is used to act as a "sun" for your scene, providing a constant source of light from one direction that causes for shadows and other lighting effects. You will usually only have one of these active at a time.
    • PointLight2D is used for individual sources of light such as lamps, car headlights, flashlights, candles, etc. These are small light sources that cast light from a central point, and there can be many of these in a scene.

    These two light types are very standard and are used across many different game engines, so there are plenty of resources online for how to use them to make nice looking scenes and effects!