The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

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!

in Engine by (519 points)

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

1 Answer

0 votes

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 : https://docs.godotengine.org/en/3.0/classes/class_input.html?highlight=input#class-input-get-joy-axis

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

by (27 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 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.