0 votes

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.getjoyaxis(0, JOYAXIS2) is the X axis
Input.getjoyaxis(0, JOYAXIS3) is the Y axis

in Engine by (12 points)

1 Answer

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

The above is pseudo code

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

by (206 points)

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!

I found this in the documentation, there is a deadzong related function

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.

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

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.