Make weapon rotate according to joystick

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

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

:bust_in_silhouette: Reply From: jgodfrey

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…

Thanks, it works perfectly!

AbDevTM | 2023-01-02 08:50