0 votes

I have a weapon and I want to make it rotate according to my touchscreen joystick. Like I want the weapon to rotate according to the joystick vector

Godot version 3.5
in Engine by (31 points)

1 Answer

0 votes
Best answer

So, you just want to set the rotation property of the weapon to the angle of your joystick? If so, something like this should work:

_process(delta):
    $Weapon.rotation = joystick_vector.angle()

Obviously, you'll need to update the $Weapon node reference and the name of the variable holding your joystick vector...

by (19,300 points)
selected by

Thanks, it works perfectly!

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.