3D Top-Down aiming system

I am building a 3D (top-down) spaceship arena shooter for my very first project to learn most of the basics.
The camera is static and you fly over the screen and shoot at meteors that fly towards you.

I want to support gamepads as well as mouse and keyboard.
Now my question:
I move the player character (spaceship) across the screen with WASD and want to aim with the mouse. The mouse should feel like a gamepad joystick. I want a circular area in the middle of my screen that my mouse can’t leave.

So if you move the mouse inside the circle the degree gets passed on to the rotation of the spaceship (independent from where the spaceship is on the screen).
So I have to translate the Vector2 of the XY mouse movement to the Vector3 of the spaceship and somehow limit the range my mouse can travel.
Unfortunately, I have zero experience with game programming (only basic Java programming) so I have no clue on how to implement a system like this.

Do you have a good tutorial that explains what I need to do?

So far my movement looks like this.
The closest system I could find to compare my vision to is Laser League.

Well you have 2 problems, one is to get the rotation angle and the second is to limit the range.

To limit the range you need to compute the mouse distance from the center point which is simply sqrt((mx-cx)^2 + (my-cy)^2).

However since we are in 3D and the camera may move you can use Vector3.Distance and you’ll have to use ScreenToWorldPoint to get the mouse position in 3D space.

For the angle you need to find the angle between 2 points (or vectors):

1 Like

That’s it. I didn’t know yet the difference and function between local and worked point, but after your comment and further research, this is exactly what I needed. Thank you!
I’ll post project updates for future people who may encounter the same problems.