Hi, new to Godot (using version 3.4). The following code sample rotates the spring arm & therefore camera around the player:
func _apply_joy_stick_rotation():
var joy_stick_axis_vector = Vector2.ZERO
joy_stick_axis_vector.x = Input.get_action_strength("look_right") - Input.get_action_strength("look_left")
joy_stick_axis_vector.y = Input.get_action_strength("look_up") - Input.get_action_strength("look_down")
if InputEventJoypadMotion:
player.rotate_y(deg2rad(-joy_stick_axis_vector.x) * joy_stick_sensitivity)
rotate_x(deg2rad(joy_stick_axis_vector.y) * joy_stick_sensitivity)
I tried modifying the above by rotating the spring arm around its y-axis if the player isn't moving (to horizontally orbit the player) & making its y rotation relative to the player's (parent node) rotation if the player is moving (like in the 1st code sample):
rotate_x(deg2rad(joy_stick_axis_vector.y) * joy_stick_sensitivity) #spring arm rotation
#making spring arm orbit player when not moving, else rotate with player
if player.get("move_direction") == Vector3.ZERO: #if player isn't moving
rotate_y(deg2rad(-joy_stick_axis_vector.x) * joy_stick_sensitivity) #spring arm rotation
else:
player.rotate_y(deg2rad(-joy_stick_axis_vector.x) * joy_stick_sensitivity)
The horizontal orbiting works fine, but now the spring arm's x rotation goes off axis & rotates uncontrollably:

It rotates uncontrollably especially when it returns my clamp (doubt the clamp is a problem, just mentioning for context):
func _physics_process(delta):
rotation.x = clamp(rotation.x, deg2rad(-55), deg2rad(55))
Please tell me what I'm doing wrong.
I followed the rayuse rp's "How To Make A 3rd Person Controller With Full Gamepad Support" tutorial for context.