Thanks for you library.
Changing the scale of the 'Base' node causes it to behave abnormally. Below seems to be one of the ways to fix it.
func _move_base(new_position: Vector2) -> void:
_base.global_position = new_position - _base.pivot_offset * _base.get_global_transform_with_canvas().get_scale() # <-- Add _base.get_global_...
func _update_joystick(touch_position: Vector2) -> void:
var _base_radius = _get_base_radius()
var center : Vector2 = _base.global_position + _base_radius
var vector : Vector2 = touch_position - center
var c = clampzone_size * _base.get_global_transform_with_canvas().get_scale().x # <-- Assuming scale x and y are the same
var d = deadzone_size * _base.get_global_transform_with_canvas().get_scale().x # <-- Assuming scale x and y are the same
vector = vector.limit_length(c)
if joystick_mode == Joystick_mode.FOLLOWING and touch_position.distance_to(center) > c:
_move_base(touch_position - vector)
_move_tip(center + vector)
if vector.length_squared() > d * d:
is_pressed = true
output = (vector - (vector.normalized() * d)) / (c - d)
else:
is_pressed = false
output = Vector2.ZERO
if use_input_actions:
# Release actions
if output.x >= 0 and Input.is_action_pressed(action_left):
Input.action_release(action_left)
if output.x <= 0 and Input.is_action_pressed(action_right):
Input.action_release(action_right)
if output.y >= 0 and Input.is_action_pressed(action_up):
Input.action_release(action_up)
if output.y <= 0 and Input.is_action_pressed(action_down):
Input.action_release(action_down)
# Press actions
if output.x < 0:
Input.action_press(action_left, -output.x)
if output.x > 0:
Input.action_press(action_right, output.x)
if output.y < 0:
Input.action_press(action_up, -output.y)
if output.y > 0:
Input.action_press(action_down, output.y)
Thanks for you library.
Changing the scale of the 'Base' node causes it to behave abnormally. Below seems to be one of the ways to fix it.