This code snippet enables a button to hit a 2D golf ball in a direction opposite the cursor. The code assumes a top-down view of the ball.
This code snippet will rotate a node in the direction of the current mouse position with a limit on the rotation speed.
The Raycast2D node can be combined with the Line2D node to create a laser that sweeps a room and can be occluded by other objects. Raycasts are particularly useful for shooters and stealth games.
You can make a moving tiled background in Godot 4 using a single TextureRect and a shader instead of multiple sprites. I learned how to create this effect from a Reddit comment and adapted it to make the scrolling effect controlled via scripting. This approach is well-suited for background elements and also has the bonus of being size-independent.