Godot Version
4.3
Question
I wanna spawn the lasers randomly going right and delete them when they go off the screen how can I do that (btw incase if it was unclear the lasers are static)
4.3
I wanna spawn the lasers randomly going right and delete them when they go off the screen how can I do that (btw incase if it was unclear the lasers are static)
You can create new nodes and add them to the scene with add_child()
. You can delete nodes with queue_free()
. If you have a fixed camera and are moving the nodes, you can keep an eye on node.global_position.x
to see when they’re far enough away to delete. See the rand...()
functions for how to generate random numbers.
You can make things move in their _process()
function by adding their speed (or the camera speed…) multiplied by the delta argument to each thing’s “x” position.
There are lots of ways you could do this: