This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Hi,
I have some issues with gamepad controls. I want to aim around player node using sticks X and Y axis. Instead of smooth movement in 360 degrees range, it aims every 45 degrees. Aiming in directions between those angles is possible, but rather hard. May it be fault of the gamepad? Is there any possibility to make aiming with stick more smooth and precise?
My code for now:

func control(delta): 
if abs(Input.get_joy_axis(0, JOY_AXIS_3)) > deadZone or 
    abs(Input.get_joy_axis(0,JOY_AXIS_2)) > deadZone:
              cannon_stick_dir = Vector2(Input.get_joy_axis(0, JOY_AXIS_3) * -1, 
                      Input.get_joy_axis(0, JOY_AXIS_2))
var cannon_position = $Cannon.get_rotation()  * 0.85 #* 1.10714872  
if cannon_position != cannon_stick_dir.angle():
    cannon_dir_vector = Vector2(cos($Cannon.get_rotation()), 
            sin($Cannon.get_rotation()))
    if cannon_position != cannon_stick_dir.angle():
        if cannon_dir_vector.angle_to(cannon_stick_dir) >= 0:
            rot_dir -= 1
            $Cannon.rotation = (rot_speed * rot_dir * delta) 
        elif cannon_dir_vector.angle_to(cannon_stick_dir) < 0:
            rot_dir += 1
            $Cannon.rotation = (rot_speed * rot_dir * delta) 
        else:
            rot_speed = 0
in Engine by (13 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.