3D side-scrolling shooter: Getting the player to aim at the mouse onscreen. (C#)
So, I know there are plenty of people asking for something like this, but every single method I've found doesn't work, for some reason, even after understanding exactly what everything does in each method, so now I'm done pulling my hair out over it, and just throwing up a new question about my situation, specifically.
A lot of the questions I've seen about it are in regards to either a 2D game, or a 3D game, where the world space doesn't really change.
To give you a bit of context, what I'm working on is essentially a 2.5D side-scrolling shooter, but throughout the levels, the player (and the camera with it) will rotate through the world, such as to go around corners. What I need right now is for the gun of the player to rotate along its X axis to follow the mouse's screen position. No matter which way the player itself is facing, the X axis of the gun will always rotate it the right way, since it's a child object of the player. The other axes of the gun's rotation must always be 0.
Every solution I've found pertaining to making an object look at the mouse always rotates more than the X axis, and freezing the other two axes cause the solution to break. I can't for the life of me figure out how to get it to rotate along only the X axis, and still look directly towards the mouse, no matter where it is onscreen.