How do I aim towards the cursor in 3D?

Godot Version

4.7

Question

I’m trying to make a very small shooting gallery mini game in which the camera doesn’t move at all. I want to make it so the projectiles spawn and fire in the the direction of the cursor/reticule. I’ve come close a few times but I just can’t get it right. What would be the best way to handle this?

Use Camera3D::project_ray_normal() to get the direction vector.

That approach should work well here since the camera stays fixed, and you can use the ray direction to aim the projectile at the cursor.