# How to translate the position of a gamepad analog stick to a rotation? (twin stick shooter)

Attention Topic was automatically imported from the old Question2Answer platform.

I have a 3D sprite model. One of the children of that sprite is a weapon (KinematicBody node). I want to rotate that weapon along the Y axis based on the position of the analog stick. Eg. if the analog stick is pointing to the left I want to point the weapon in the same direction (360 degree coverage). Think games like Enter the Gungeon.
For reference, I’m using an XBox One controller
Input.get_joy_axis(0, JOY_AXIS_2) is the X axis
Input.get_joy_axis(0, JOY_AXIS_3) is the Y axis

``````if y>=0:
if x==0:
r=PI/2
else:
r=atan(y/x)
elif y<0:
if x==0:
r=PI/2+PI
else:
r=atan(y/x)+PI
degrees=r*360/(PI*2) (0~360)
``````

The above is pseudo code

position== (1.0,0.0) => degrees==0

does godot have deadzone support built in? if so, how do you customize that? (I checked the input docs, I don’t see any reference to configuring deadzone)

if godot doesn’t handle deadzone, make sure you do!

Jason Swearingen | 2020-01-07 13:20

I found this in the documentation, there is a deadzong related function
InputMap — Godot Engine (latest) documentation in English

It seems that you don’t know much about trigonometric functions. If this is the case, no matter how I help you,it will be difficult for you. You should all learn trigonometric functions.

ATom 1 | 2020-01-07 14:59

thanks for the link on deadzones! I swear I searched for that but didn’t see it

Jason Swearingen | 2020-01-07 18:08