0 votes

Hello, is it possible to add LightOcclusion2D to an animated sprite? If it isn't what other way of creating shadows do you suggest?

in Engine by (20 points)

1 Answer

0 votes

Did you try it?

Yes, you can attach LightOcclusion2D to any node, not just Sprite/AnimatedSprite. Thats the great thing about node hierarchy :)

However, LightOccluder2D is really a (2d) polygon, so it will not magically transform from your AnimatedSprite, you have to draw it / animate it (if you are making just top down game and simple "circle under feet" is enought, you dont have to animate anything)

You have many options how to do that. You can use frame_changed signal and turning on/off your occluders or you can use AnimationPlayer... There are many possible solutions and "how to do it"... Just depends...

My personal recommandations?

Heavily opinion based?

If you are trying to do something trivial, for example "open / close" door, i would just add two LightOccluder, draw two polygons and keep switching them in "func openDoor():" / "func closeDoor():" (you will be switching path finding down the line, so... Sooner or later :) )

If you are trying to do something super nice and cool, for example main character? I would stay away from AnimatedSprite and use KinematicBody with Skeleton, bunch of Sprites and AnimationPlayer (and ends up with chracter like in Salt&Sanctuary.)

But as i say, it depends what is the effect you are after...

By the way: Experiment with Closed & Cull modeon your ShadowOccluder2D - you can do really nice effects with it (like, your light cast shadow only from one side - you can simulate things "lamp is behind / in the front of wall and still be 2 dimensional"

by (233 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.