0 votes

Hello! I was faced with the problem of rendering shadows in Godot and I had a question how exactly can I fix this?
https://imgur.com/JyLgPy8

However, while I was trying to change something, I came across one idea. Make the shadows by hand. Like this:
https://imgur.com/2eOUohF

But the following question arose: how to realize the rotation of this sprite from a light source so that the artificial shadow behaves realistically?

I tried to use Area2D, but this does not work correctly

in Engine by (65 points)

You could make vector calculations with the location of the light and the object (e.g. rock.global_position.angletopoint(light.global_position) gives you https://docs.godotengine.org/en/stable/classes/class_vector2.html#class-vector2-method-angle-to), and get the rotation of the object. But it seems complicated - but doable - to get the shadow's rotation and length from these. You would also need to create several shadows based on direction (e.g. one with light between the characters legs and one w/o).

Is it possible to do this if the player and the light source are created by separate scenes, without creating a global singleton?

Well I'm not an expert but you could avoid using a global singleton with groups (https://docs.godotengine.org/en/3.2/getting_started/step_by_step/scripting_continued.html#groups).

Please log in or register to answer this question.

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.