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

in Engine by (24 points)

1 Answer

+1 vote
Best answer

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.

by (113 points)
selected 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.