0 votes

I want to make a light when touch or click,for example all the screen is dark but when I touch in any part it will illuminate (so the player can watch the game) in a radius but only for one second, then the ligth start go off slowly. When I touch the light starts expanding in a radius and after one second It will start go off, but i dont have idea how to do it, can anyone help?

in Engine by (16 points)

1 Answer

0 votes

Here's how I think you can solve your problem.

  1. Have a light node of some kind (e.g. a Light2D) that has an Area2D attached to it. Set the signal of the Area2D (the area_entered or body_entered signals, whichever one you're using for your character) to be emitted when the character enters the Area2D or when the player clicks on the Area2D.
  2. Set the Light2D to "visible" when the character enters the Area2D. The expansion part is a bit more difficult, becasuse Light2D requires a texture to define which parts are lighted (it's a grayscale image with values in between white and black). You may have to write a shader to make that expand.
  3. Once that expansion problem has been solved, set a Timer and use the timeout() signal of the Timer to make the Light2D invisible after 1 second.

For more information on lights and shadows, see the official documentation on the subject. With regards to Signals, see the documentation on that subject. Finally, learn more about Area2Ds from the documentation.

by (2,080 points)
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.