How would i make a bullet stop and delete itself when it collides with the mouse position when it had fired

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Boxx Ross

so in my game, I have a flare weapon which I want to act as a light source when it collides with the mouse position, to clarify i mean where the mouse was positioned when the player fired the flare, so ideally, it would travel until it hit where the player had targeted it and I would from there be able to swap out a flare object in its place.

I’ve tried a lot of different methods but the one that’s been the closest, is the method where when I fire I spawn a crosshair indicator showing i fired at that spot, but at the center of the crosshair there is a collision stored on it or an area2d, so when the flare hits the center of the crosshair, it can detect its hit a “block” and it can do all the things i mentioned above

I’ve gotten most aspects of this to work, the only thing not working is the detection for deleting the bullet as when it collides it comes to a stop and stays there until the timer i have set deletes it which is way too long. the bullet and crosshair are completely different scenes btw, as well as different codes, any ideas?

:bust_in_silhouette: Reply From: Fumbling Welli

What about, after firing the bullet if the bullet hits the mouse cursor it will make it stop? and when it stops you can make the energy of the light2d node go up like this Idk I am not expert.

func fire():
   var ene =  $
   var pos = get_global_mouse_position()
   if (your bullet).position = pos
       (your bullet).position = pos
       $ = ene + 1.5

and soory if its misleading or wrong