0 votes

When you drag the joy stick around it will trigger or like press the keyboard buttons, I don't know how to explain it properly so I hope you get the idea by this graph

/-Min-/ - /-Max-/ - /-Keyboard Keys-/
337.5° - 022.5° - D
022.5° - 067.5° - D + W
067.5° - 112.5° - W
112.5° - 157.5° - W + A
157.5° - 202.5° - A
202.5° - 247.5° - A + S
247.5° - 292.5° - S
292.5° - 337.5° - S + D

I want to know if this idea is possible, if so how?
I want to implement this on moving the Player.

Godot version v3.2.2
in Engine by (14 points)

1 Answer

+1 vote

Map your Left Joy Axis Left, Left Joy Axis Right, Left Joy Axis Down, and Left Joy Axis Up in your Project-> Project Settings -> Input Map then write an additive input event handler:

var direction_vector = Vector2.ZERO
if Input.is_action_pressed("left_joy_left"):
    direction_vector += Vector2.LEFT
if Input.is_action_pressed("left_joy_down"):
    direction_vector += Vector2.DOWN
if Input.is_action_pressed("left_joy_right"):
    direction_vector += Vector2.RIGHT
if Input.is_action_pressed("left_joy_up"):
    direction_vector += Vector2.UP

So if you have your joystick rotated up and left: direction_vector = Vector2.UP + Vector2.LEFT = (-1, -1) which would be equivalent to you pressing W + A in most games.

by (2,176 points)
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 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 webmaster@godotengine.org with your username.