GUIDES

How to add 2D Shadows in Unity

Creating a visually appealing 2D game isn’t just about great artwork. It’s about depth, contrast, lighting and yes, shadows. But how do you create 2D shadows in Unity? Today, I’ll show you how simple its to add shadows to your 2D game in Unity.

Video Tutorial

Getting Started with Unity’s 2D Lights

Unity has a powerful 2D Renderer as part of the Universal Render Pipeline (URP). To enable shadows, you need to make sure your project is set up correctly. If you have created a new 2D URP project, you don’t have to worry about this, you can directly go to setting up your lights and shadows.

If you are not using URP here’s how to switch:

  1. Right click on your project window and go to Create >Rendering >URP Asset(with 2D renderer). If you don’t see the option, then install the URP, 2D renderer package from package manager.
  2. Go to Edit > Project Settings > Graphics and assign the URP Asset you created.
Unity Project Settings showing URP enabled.

Adding a Light Source

Once URP is set up, we can add 2D Lights to the scene.

  1. Create a Light – Go to GameObject > Light > Spot Light 2D.
  2. Adjust the Light Settings – Set the Intensity, Color, and Radius to match your game’s aesthetic.
  3. Enable Shadows – Check the Cast Shadows option in the Inspector panel.

Making Objects Cast Shadows

Now, just adding a light isn’t enough. We need objects to actually cast shadows!

  1. Select the 2D game objects which needs to cast shadow. Make sure they have sprite renderer component.
  2. Add a Shadow Caster 2D component (AddComponent > Rendering > Shadow Caster 2D).
  3. Ensure the Self Shadows option is enabled if you want internal shadows.
  4. Play with the settings to get the best look.

Fine-Tuning the Shadows

Shadows can make or break the visual appeal. Some tips I found helpful:

  • Adjust the Light Falloff to make soft or hard shadows.
  • Experiment with multiple light sources for dramatic effects.
  • Use Normal Maps on sprites to add depth.

Conclusion

Adding 2D shadows in Unity is easier than you think! With URP and 2D lights, you can bring your game to life in just a few steps. If you’re working on a 2D game, give shadows a try. It makes a huge difference!

Have you used 2D shadows in Unity before? Let me know your experiences in the comments!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button