Godot Version
4.4.1
Question
So I’ve made a joystick for a top down RPG I’m making. I followed a tutorial and changed some things to fit my game. For some reason the center knob is duplicating itself whenever I move the sprite. I’ve been playing with it for a while now and can’t seem to figure this one out.
Here’s my code for the knob’s movement:
if pressing:
if get_global_mouse_position().distance_to(parent.global_position) <= maxLength:
global_position = get_global_mouse_position()
else:
GameManager.angle = parent.global_position.angle_to_point(get_global_mouse_position())
global_position.x = parent.global_position.x + cos(GameManager.angle) * maxLength
global_position.y = parent.global_position.y + sin(GameManager.angle) * maxLength
calculateVector()
else:
global_position = lerp(global_position, parent.global_position, delta*10)
GameManager.posVector = Vector2(0,0)
And here’s a picture of what the knob is doing in game:
The movement is working fine, I just can’t seem to get that duplicate knob to go away!
Thank you!