Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+11 votes

Does anyone have any idea about how to implement the lighting move along mouse cursor similar to the game that win the Go Wild Jam?

asked in CSC380Jan2024 by (2.6k points)

2 Answers

+5 votes

You should start by adding a Sprite node to depict your game environment and a Light2D node for the lighting effect. Then, you should create a script for the node handling the light movement. The script should use the get_global_mouse_position() function to retrieve the mouse cursor's position on the screen. and then the linear_interpolate method could also be used to adjust the position of the light node towards the mouse cursor over time in a smooth way. The speed of this movement could be controlled by the follow_speed variable, thats how you can keep track the responsiveness of the lighting effect. finally, you could customize the Light2D node's properties, such as color and radius, to specify how you want it to look.

answered by (3k points)
0 votes

I used a light2d to achieve this feature. light looks so cool in game.

answered by (2.3k points)