Download

[HELP] Creating Hotbar/Ability Bar With GAS(Gameplay Ability System)

hi so ive been searching for ways to create hotbar using GAS for a while now and want to ask for guidance.what i want to do is create action bar with ability window where u can drag the ability onto the bar like in most mmorpg there are skilltree where u can drag and drop onto the hotbar.

have anyone do something similiar to this and willing to share how you manage to get it working

I’ve done something like this past, in C++ , basically In your icon widget You need to tinker with


virtual void NativeOnDragDetected(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent, UDragDropOperation*& InOperation) override;
    virtual bool NativeOnDragOver(const FGeometry& InGeometry, const FDragDropEvent& InDragDropEvent, UDragDropOperation* InOperation) override;
    virtual bool NativeOnDrop(const FGeometry& InGeometry, const FDragDropEvent& InDragDropEvent, UDragDropOperation* InOperation) override;
    virtual void NativeOnDragLeave(const FDragDropEvent& InDragDropEvent, UDragDropOperation* InOperation) override;
    virtual void NativeOnDragCancelled(const FDragDropEvent& InDragDropEvent, UDragDropOperation* InOperation) override;

And in some tick keep an eye on icons


if (bDragging == FALSE)
    {
        if ((UIQuickBar->GetVisibility() != ESlateVisibility::Visible ||
            !UIQuickBar->IsHovered()) &&
            UIQuickBar->nIndex == -1) return;

        UCanvasPanel* Buttons = (UCanvasPanel*)UIQuickBar->GetWidgetFromName(TEXT("Buttons"));
        int32 nIndex = -1;
        if (Buttons)
        {
            for (int32 i = 0; i < Buttons->GetChildrenCount(); i++)
            {
                if (Buttons->GetChildAt(i))
                {
                    if (Buttons->GetChildAt(i)->GetName().Contains(qkbSkill))
                    {
                        if (Buttons->GetChildAt(i)->IsHovered())
                        {
                            FString s = Buttons->GetChildAt(i)->GetName();
                            FString sInt = s.Replace(*qkbSkill, TEXT(""));
                            nIndex = FCString::Atoi(*sInt);
                            if (UIQuickBar->nIndex != nIndex)
                            {
                                UIQuickBar->nIndex = nDragTo = nIndex;
                                UIQuickBar->HandleIconPosition();
                            }
                        }
                    }
                }
            }

            if (nIndex == -1 && UIQuickBar->nIndex != -1)
            {
                UIQuickBar->nIndex = -1;
                UIQuickBar->ResetSlots();
            }
        }
    }
    else
    {
        for (int32 j = 0; j < MAX_SLOTS; j++)
        {
            if (vDragPos.X + nQuickBarIconSize / 2 > UIQuickBar->GetRelativeSlotPosition(j).X + nQuickBarIconSize / 3 &&
                vDragPos.X + nQuickBarIconSize / 2 < UIQuickBar->GetRelativeSlotPosition(j).X + nQuickBarIconSize)
            {
                if (nDragTo != j)
                {
                    UIQuickBar->nIndex = nDragTo = j;
                    if ((bDragItem && nDragTo >= MAX_SLOTS_SKILL) ||
                        bDragItem == FALSE && nDragTo < MAX_SLOTS_SKILL)
                    {
                        UIQuickBar->HandleIconPosition();
                    }
                }
            }
        }
    }

This is some pretty old code, there may be easier way now

;tldr
Look into


NativeOnDragDetected

do u have a discord btw?i havent start yet making it like the image the slot etc…would like to talk bout this since you have experience with it

We are all here https://unrealslackers.org/

You can try looking at the UI for Strategy Game cpp code. They have implemented in Slate framework, though drag and drop and action bar and item slots is somewhat common functionalities.