Action bar slots problem when assigning the skill on a specific slot..

I have this action bar that has many slots and each slot has its own key assigned to it. The problem i have is when i drag a skill on it. When i then press any of the action bar slot keys it executes the skill just like when the skill was dragged to all slots at the same time :frowning:

I have this logic where it checks which slot is assigned to which key exactly. It seems that it does not work for some reason.

and here the skill on the actionbar… No matter where it is any key from the action bar will execute the skill.
bandicam 2023-07-03 13-26-48-144

I hope someone can help to fix this. The branch on the first screenshot after the key bindings are checked for each individual slot returns the message key pressed when i press any of the key’s.

Are you using named slots? Namely:

image

Asking, as there should never be any need to loop through anything to do something like this. You press the slot key and execute what’s in the relevant slot directly.


Worst case scenario in some uncanny and unique setup, I’d map key-widget. I am judging by the description but may not see the whole picture here, ofc.


The usual way of doing this:

  • a user widget with a Named Slot

You then tell the user widget to execute what’s inside its NamedSlot, do nothing if no child is present. This make re-parenting and handling drag & drop pretty straightforward.


Re: original question:

image

If this triggers for all - the mapping is incorrectly set up. What do you get when you print-compare the keys?

My slots look similar they do have a name.

I made them from this tutorial https://www.youtube.com/watch?v=UjidNRD-hSU
and on part 2 of it is where those action bar slots the keybindings of them can be changed on the go not sure if that was the loop for…

How can i do that ? I wanted as well to find out how to print string individual slots…

I dont think i used those “named slots” it was a normal button. Here is the individual slot alone and how it looks like

I really appreciate the help on this one. I think (not 100% sure) yestarday it worked i dragged a skill and i could use on the individual slot key the skill but something happend or i changed something. I dont know what happend and it stopped working . I’m sitting scince yestarday working on this but i cant make it work again. Today alone im sitting around 5-6 hours on it and i dont know how to make this to work

Keys have names so you check out what you’re comparing to what:

Judging by what you’re saying, this always returns true:

image

Not sure how this is supposed to work:

  • Key is static? I don’t see you SET it here (but you probably do somewhere)
  • Mapping is different in every widget? if so, how are you doing it? Via an exposed variable? somewhere here?

So, either Key is never set or Mapping is identical across all widget instances. That’s my best best at this point.

The keys are set here from his tutorial part 2 @ 15:15 Unreal Engine 4 Tutorial - Key Bindings Part 2: Changing Bindings - YouTube

They are here

So when you print it, it actually makes sense?

Add a breakpoint and step through to see what is going on.

On my last screenshot i can open the keybinding window and set a key to a different one and it updates it immidiatly. Lets say the action bar slot 1 to RMB (right mouse button) then i see it changed to RMB… I’m not sure what to do now or where to print string to check that.

here, with breakpoints


Btw, this is a 2 year old tut. If you’re using UE5, the old input systems are now deprecated. So I’d need to assume the tutorial it is not using Enhanced Input which supports a much better key mapping system.

I’m expecting Epic to completely phase out the old input at some point. Usually takes a year or so. The legacy currently works. I now see the tut is using Input Selector - it’s been a couple of years since I dabbled - not sure how much assistance I can offer here, would need to refresh my memory - it’s just not a worthy investment at this point.

But printing the results should give you a clear overview regarding what is being checked against what. I’d start there.

Ok i made it like you say here

and i pressed all the buttons 1 by 1 starting from 1 then 2,3,4,5… and so on here is what came out-

Is this not working ? it seems when i press key 1 it is counted as 1 and so on. Why i cant put my skill on slot 1 and use key 1 to trigger it ? if i drag my skill to slot 1 any other slot key will trigger it as well… Am i connecting my skill at the end (after the print string was) to execute the skill false there ?

So yeah, the result is always true, as expected. Look into the logic of how this is supposed to work then - I cannot tell from the snippets provided. Why is the mapping and key always the same?

Assuming the mapping is correct - why is the key behaving like this? Are you calling Check Binding in a loop as well and provide a new key?!

Should they not be the same?

No im not looping the “check bindings” function anywhere.
Is this not working as it should when pressing key one and print strings 1 as well then 2 and so on ?

Actually there is outside the check binding in the event graph this one

Not sure if that cause problems but was on his tutorial and when i disconnect it then those check bindings dont print string anything anymore

I think it’s working correctly, you’re comparing the wrong thing in the wrong place. You’re checking for corresponding keys and they do, indeed, seem to match up nicely.

This is the time to send a message to the underlying widget to execute its ability if it has one. You’re dropping widgets into slots - how does a slot currently know it has something - a widget ability - to execute?

This is your slot:

image

When happens when you drop? You must be storing a reference to what you dropped, right? Or setting some kind of value? An enumerator? Int? String? Something that tells you what sits in the slot. Perhaps each ability is a widget? How does it work?

Any idea how can i do this ?

i put a custom event on my player character bp which connects to the skill i want to trigger. Then in the check bindings i try to connect the custom event but it triggers it on any key… I assume i need to put the trigger logic when i press the key somewhere else but not on check bindings right ? i awso try to reverse it and get check bindings to my character bp and trigger the skill but it isnt working …

The cast button has this on it to know something get dragged to it


Where should i put the skill on to trigger it when pressing the key ? Theonly thing that worked was on check bindings but it triggers it on any key. The same happens if i move the skill on the skillbutton itself same result

The skilldata structure from which it knows when i drag a skill from my skill tree only stores the basic information how the skill looks like (skill image/icon) and description text but it has no idea what the skill does or how it triggers. The skill is separate on my character bp and i have it there either on a pre defined key like “E” for example and i want to move it to the action bar keys if i only know how i can trigger a skill from there. If i press key 1 and it print strings 1 should i not put my skills in connection to this function somehow? Where would you put the skill to be triggered when pressing the actionbar keys ?

OK, I see. This is not set up correctly. Essentially:

Your slots have no idea what they contain apart from an image. So they cannot execute what is needed.

This will never work:

Is this part of the official tutorial?


I saw you have 20+ slots. Does this mean that the player already has all the abilities?

Hold, on you give them a struct. :+1: But this struct contains no data regarding how the ability works, right?

I saw you have 20+ slots. Does this mean that the player already has all the abilities?

This is a bit scary. How many abilities are you planning for?

No is not part of the tutorial and i am combining 2 tutorial of his but they are separate and does not contain info how to trigger skills only how the skilltree is build with the data struckture and data table. So i can open my skill tree purchase skills then drag the skills to my action bar and i see the images updating i can move them from 1 slot to the other. But the data structure dont tell them anything where the skill itself is located or how to trigger it. I need to somewhow link my skill to be triggered when i drag skill X… the skill itself on the skill tree with the icon does acctually know that “teleport skill” is the teleport skill because it unlocks it and i could then click on it on the action bar or better say i can press the key after i drag it down there. But all the keys trigger the skill hmm

No they are locked on the skill tree and once purchased then i can use them and unlock them not befor that…

A skill looks like this for example

I need to only replace the predifined key 1 to the action bar key to start executing it somehow so maybe with a custom event and then call this custom event on the key i press on the action bar. If i can do that then this will be solved. But when i try to change the 1 key with custom event and connect the custom event to the “check bindings” for example it iant working properly then any action bar key triggers it. But it seems to work partially . I need to purchase on the skilltree the skill first then drag the skill on the action bar and then i can trigger it - the only problem is that any key from the action bar triggers the skill and not the specified key on the action bar where i dragged the skill…

No they are unlocked on the skill tree and once purchased then i can use them not befor that

But that means it’s the player that implements skill functions, right:

So you have a massive list of abilities the player already knows upfront, not matter how many they’ve unlocked so far.


We can work with that but it’s not the way to do it. This will be nightmare to refactor in case you ever need to change how things work. Can we see what’s in the struct? Is there some kind of ID a skill has, a name? Are the names unique enough to use them?

yes thats correct

And yes they have an ID which is the skill name with a prefix Like “Teleport_Skill”
this i can then lock in the character bp and make it only usable if it is purchased with a skillpoint.

Mana cost and cast time are not even used i directly put the mana cost on the skill itself.
Problem remains tough that i only need to trigger the skill properly after i drag it on the action bar. As of now all action bar key trigger the skill when i drag it anywhere on it

If those key print string correctly the keys i am pressing on the action bar, then how would i go about to make this key i am pressing to acctually trigger the skill (instead of all action bar keys to trigger it) ?

Yeah that’s correct. All my skills are on my character right now

Edit:

The skill tree shows all the skills and the player has them all in the playerBP but they are locked in the beginning logic of the skill so they cannot be used unless they are purchased with a skill point. So befor that they are not usable. Not sure if this answers the question if the player “knows” the skills but thats how the skill work.

We can work with that but it’s going to be UGLY. :face_holding_back_tears:

Disclaimer

Please do not use this method for a new system - this is just a workaround for the existing one.

  • in the player, the skills are the functions you’ve got:

As you can probably see, this is not great.

  • the UI Slot widget:

Call the above here:


I don’t like this.

1 Like