0 votes

I know this will sound a bit silly, but I am trying to use a light to accurately find what positions will be affected by an explosion. If possible, i would also like to know how to find the level of illumination.

If it helps, I am using version 3.1.1

asked Sep 22, 2019 in Engine by rami-slicer (16 points)

1 Answer

+1 vote

You can check the distance between your Light2D and each item. Vector2 already has a built in distance_to function. Then you do something like light.texture.get_size() * light.texture_scale and see if the distance is less than that. As for level of illumination, I guess you'll have to scale it by how far something is from the center of the light.

Just thought of this one. Alternatively, you can add a CollisionShape2D as a sibling of the Light2D, and both a child of some collision body, and let that find out if anything is inside. The thing creating the explosion and the things affected by the explosion would have to be some kind of collision body for this to work.

answered Sep 22, 2019 by epark009 (82 points)
edited Sep 22, 2019 by epark009
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.