0 votes

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
Godot version 3.5.1 stable
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.