That’s about my 4th version of a mouse aim system. The first one was like yours, but I wasn’t happy with the way it traced into walls or stopped working if no actor was beneath the cursor.
Then I googled formulas for tracing hits on a plane, then found out that unrealengine has one already. I already knew how to do screen to world traces from something I did in UE3
Finally I put all that knowledge together using the same patten that the UE engine provides for doing actor under the cursor trace.
So basically 16 years in the Unreal engine and some Google queries
Glad it sorted things for you.