Hello, i making a game, where character have a stretching arm that following cursor and i a faced problem of hand part. I’m trying to limit it’s range and right now the only working way i know works bad: it’s look like i’m moving mouse too fast for game and hand just got left hanging at it’s place, but when i move cursor to center of it it’s starting to follow cursor if i move it very slow, of course.
extends Area2D
var max_distance = 8
func _physics_process(delta):
var hand_position = get_global_transform().origin
var cursor_position = get_global_mouse_position()
var distance = hand_position.distance_to(cursor_position)
if distance <= max_distance:
global_position = cursor_position
func _unhandled_input(event):
if event.is_action_pressed("left_mouse_button"):
$hand_sprite.scale.y = 0.3
else:
$hand_sprite.scale.y = 0.5
So, is there is some better way i can make this or i just messed up what i have?