Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Radinyn |
Hello, is it possible to add LightOcclusion2D to an animated sprite? If it isn’t what other way of creating shadows do you suggest?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Radinyn |
Hello, is it possible to add LightOcclusion2D to an animated sprite? If it isn’t what other way of creating shadows do you suggest?
Reply From: | splite |
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 mode
on 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”
Sorry, Working with Light recently I’ve realized alot of people have the same questions I did. Light occluders are going to be used for static objects, Walls, buildings ect. You want to use Canvas Item Material in the CanvasItems section for things that are animated. this will occlude light based on the sprite. Specifically for animated 2d sprites I would use a Normal Map.