How to use the rigth stick as the mouse?

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

Hey there!

I’m trying to add compatibility with controller for my game. So far, everything is fine except one thing? How can I use the right stick as the mouse position?

The aim of my game is controlled with look_at(get_global_mouse_position()) (it’s a top-down 2D game) and I would like that the right stick performed the same function.

Thanks in advance!

Did you manage to get it working? I am in the exact same situation and the answer didn’t really help me. Thanks.

Surtarso | 2021-10-02 18:00

:bust_in_silhouette: Reply From: lazlo

You can acces the Left Stick direction of joystcik 0 Like that :

var axis = Vector2(Input.get_joy_axis ( 0,JOY_AXIS_0 ), Input.get_joy_axis ( 0,JOY_AXIS_1 ))

axis= (0,1) if at right side
axis=(0,0) if centered
axis=(-1,0) if at left side
axis=(1,1) if at top right corner
etc …
see : Input — Godot Engine (3.0) documentation in English

Warning : axis will never be equal to (0,0) or (1,1) or (-1,-1) because of the physical stick that is never really centered or at the end of bounds. so you need tocheck for a minimal diferrence