I’m making a third person tank shooter. I want the gun turret rotation of my tank to be controlled via mouse input I want the rotation of the turret to be independent of the rotation of the tank chassis. I’ve got a basic movement system written up and it rotates well for large rotations, but when it comes to very small rotations, the turret seems to snap between small angles rather than fluidly rotating from point to point, which makes aiming at small or very far away targets feel janky and not very practical.
See video below:
Here’s the code I’ve written to handle the turret rotation:
The way my code works, I’m taking in the X position of my mouse and upon change in the X Coordinate, turret either rotates left or right.
I’m also running some code that recenters the mouse cursor upon any deviation from center so that the turret only rotates when mouse is moved from one point to another and wont continually rotate in a given direction.
I would love some suggestions for how I can change my code to give more fluid rotation, or where I should start looking in order to make that happen. Thanks in advance.