Trying to make my character's weapon track the mouse more accurately

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BigSaturn

I’m brand new to the engine and very green when it comes to writing scripting. I am trying to make something like a twin stick game, I have used this FPS mouselook setup
that i got from a tutorial with some pretty good results, however i would like the weapon’s movement to more accurately reflect where the reticle is pointed.

Here is the current code i’m using along w/ a gif to better illustrate the issue. The cursor is a little hard to see but I think it gets the point across.

helpgif.gif

extends Position3D
var mouseDelta : Vector2 = Vector2()
var lookSensitivity : float = 15
var minLookAngle : float = 90
var maxLookAngle : float = -90
var _smoothed_mouse_pos: Vector2
#mouselook functions
func _process(delta):


$MeshInstance.rotation_degrees.x -= mouseDelta.y * lookSensitivity * delta
$MeshInstance.rotation_degrees.x = clamp($MeshInstance.rotation_degrees.x, minLookAngle, maxLookAngle)
rotation_degrees.y -= mouseDelta.x * lookSensitivity * delta
mouseDelta = Vector2()

func _input(event):
if event is InputEventMouseMotion:
	mouseDelta = event.relative