#UI/Control help

10 messages · Page 1 of 1 (latest)

south dawn
#

I'm basically going for a skill bar type of setup:

Anyone have ideas on how I can make it so that my UI element inside of my scroll container can be taken out of it while dragging so that I can "slot it" into the element below?

Lmk if you need more info, any help appreciated

idle turret
#

It's not entirely clear what exact functionality you're having trouble implementing

#

Removing it from the container? Adding it to the slot?

south dawn
#

Which is understandable, but i'm not sure which direction i should proceed, UI isn't my strong suit

idle turret
#

Could you share some relevant code?

south dawn
#

here's the main code for dragging and dropping for the draggable node:

    if draggable:
        if Input.is_action_just_pressed("select_input"):
            initial_position = global_position # change to reference for return
            offset = get_global_mouse_position() - global_position
            GameManager.is_dragging = true
        
        if Input.is_action_pressed("select_input"):
            global_position = get_global_mouse_position() - offset
        
        elif Input.is_action_just_released("select_input"):
            GameManager.is_dragging = false
            var tween = get_tree().create_tween() # necessary?
            if is_inside_droppable:
                tween.tween_property(self, "global_position", body_ref.global_position, 0.2).set_ease(Tween.EASE_OUT)
            else:
                tween.tween_property(self, "global_position", initial_position, 0.2).set_ease(Tween.EASE_OUT)```
#

Works fine in other scenes, I'm just not sure how to make it work with this scene since the setup of controls is peculiar

#

I was going to make it so that the parent of the draggable node is set to some other node, then on drop it would either take the body it's dropped in, or return to its origin, but it was very unsafe to do with a high potential for missing addresses which would throw errors

south dawn
#

Honestly i'm probably just going to use each slot to populate an information menu and allow assignment from there. Alternative solutions or advice on the scene tree appreciated :)