I have some action bar UI slots not even real inventory. I can drag skills in there and use them. I can awso drag the skill from lets say slot 1 to slot 3 and this awso works. Only thing i am missing is when i drag this skill from let’s say skill slot 1 to 3 i want that this same skill from slot 1 when “on drag detected” then clear/empty my slot 1. Is there some easy way to do it ? I want that my slot 1 which had the skill is getting back to default setting and be just empty. Any help as aways really appreciated.
So basicly when i drag the skill it should remove/empty the slot where it was previously befor i started dragging it (on drag detected) There should be no duplicates of the skill so this 1 skill can be moved from slot to slot but still remain a solo skill and not 3 like on the screenshot.
Don’t remove it when you start dragging, hide it instead. When you drop, add to new parent, and show it (showing may not even be necessary since Construct will fire and apply default Visibility settings, most likely)
Were you to remove it when dragging starts, you’d be risking Garbage Collection scooping the widget up - which will almost definitely happen if the widget is not hard referenced in some way. Note that a widget having a parent counts as a reference.
There should be no duplicates of the skill so this 1 skill can be moved from slot to slot but still remain a solo skill and not 3 like on the screenshot.
You’re doing something strange - you should not be getting duplicates. Payload goes in, payload comes out. A widget can only have 1 parent. If in doubt, could you show:
Would that mean that the skill is just not visible but still be in the previous slot so that it may fire /activate the skill when i press a button ?
I will try something and see if i can manage to do it. Still watching similar tutorial atm on inventory slots with index variables where this is possible with add to parent and checking which index the slot was. Which in my case my slots don’t have this varibles and work little different i think.
Yes. Flag it (or its slot) to not be available to fire during drag OP. Enable interaction after dropping. Depends what is handling ability use. The widget or its slot (I generally associate slots with execution)
Press 1 → use slot 1 → slot checks if there’s something inside → execute what’s in the slot
Technically, you could remove it from the slot and it should be safe since the Drag OP keeps track of it as Payload. When dragging starts, create drag OP → Remove from parent. Could work but is somewhat scary → you’d need to explicitly handle what happens when drag is cancelled. Or you lose your widget, it’s safer to keep in the slot during the drag OP.
but i can drag my skill and is working hmm wierd… i can drag my skill to slot 1 and if i press key 1 it fires the skill. ican drag then the skill to slot 7 and press key 7 and it fires the skill as well. Image and the rest awso move accordingly from slot 1 to 7…
What do i connect on the payload ? I have my struct with all the info for the skill with image and so on.
The widget that is sitting in this slot. Or the object that represents the ability in more complex scenarios. Where is it? How do you place a widget that represents the ability in the slot?
UI
slot 1
– ability widget
slot 2
slot 3
When you drag ability widget, you simply re parent it from slot to slot.
The widget that i drag has similar code. At least on drag detected it awso has no payload anything connected there. But additionally it has some extra code in the event graph. It is called Skill Button UI and this one has the skill info which i drag around. It looks like this
On drag detected (I’m now awso wondering why there is no payload in it as well)
and here how this looks in game. Should this acctually don’t work at all if it has no payload connected (on both the skill button and the action bar slots im dragging it to)
This is not set up correctly. I can only suggest having a look at some drag & drop tuts. Payload is the most important aspect of drag & drop - this is the actual data (which can be represented by a widget) you move around between slots.
I guess that must be it yes. But it is working so far pretty good. What info does the payload need beside the icon ? Im not sure if that would make the whole thing more complicated or if im just 1 step away to remove this skill from slot to slot by some other method maybe ? I feel that it is working pretty good as i mentioned or on the video you see that the skill is recognized on any slot and any key triggers the skill accordingly corresponding to the key that the slot is assignt to. So this works too. I hope i can just make this one further working by adding this last action i want with removing the skill from the slot somehow. I will go watch more on the payload and drag drop tutorial as well. I’m acctually watching right now.
I guess this should be the payload if it has to be a texture.
Nothing changes tough all works. I can put my skill to slot 1 and then even replace and drag new skill to slot 1 then press key 1 and it will fire the new skill… I don’t see any problem here now the part to remove it. I will reread this post and check tutorials till i find the solution
Slots should not care about any of this, slots just hold ability widgets and move those widgets around. This way the re-parenting is done completely automatically and you never worry about the things that you’re worry about in the original message. The root of the issue that this is not drag & drop at this point.
Ok let’s assume this is set up the correct way as you describe. Would it change anything on how this will work at the end ? Because as it is of right now it seems to work flawlessly with any skill. it recognizes on which slot it is and i can put a new skill on the same slot and it still then knows now is a new skill in there like here on this video:
I understand that it isn’t set up properly. But it has the exact functionality i am aiming for and i need to just remove the skill when dragging it to another slot. If there is some way to do it like this as it is would be the best for me befor i need to redo a lot of the code again to achieve the exact same result at the end. Which was very hard for me to bring it in the state as it is.
You’ve found an unnecessary workaround for a problem that does not exist. And insist on using it because you’re invested. I can’t tell what issues you’re going to run into or how to solve them because I simply do not understand what you’re doing. I can only tell you are actively working against an established system.
I wish i knew what this system is it is basicly to 95% of this system that you speak of with very small modifications. I’m myself not exactly sure how mine differ in this regard. It was made from a tutorial long ago which do try to use the system you speak about. I remember that i made few modifications to bring my skill button UI to work with my skills and the action bar slots togheter. Which now in the end finally works really nice. All now i am missing is to remove the info when i drag a skill from 1 slot to the next one. I think people have index variables on those slots and then something like the payload should move from index 0 or 1 to whatever next index slot has. I will have to dig more into this and compare how mine acctually works because i made it long ago and cannot remember fully.
Here is the tutorial i followed. It looks like he awso don’t use any payload. So i was following it correctly as it seems. The question is why there is no payload on his tutorial @ 7:05 ? I tought he is someone who knows what is doing. Maybe there is cases that have a reason to not use a payload ?
Or maybe this tutorial was never really finished just some basic functionality. Or at least it felt like it because you couldn’t do on it what i now try to solve with moving the skills from slot to slot… Anyway ty for your time and help. If i find a workaround for my stuff i will share it later.
This person skipped using payload and reinvented the wheel, just like you did (or the other way round). It can be super useful but you need to understand the core aspect of drag & drop first.
The payload data container already exists and is ready to use and present through the entire system for us to take the advantage of.
You say you want to hide the widget sitting in the slot. Then hide it.
You can do the whole thing without using Payload - but then you need to script a lot of bits yourself from scratch - you need manually move and show widgets yourself. If you’re ready for this, you’ll be fine. Creating a custom & drop op and exposing data is quite common.
It just makes no sense to me that your slots contain ability data, and you want to do it all manually. Essentially, by following the tut you’ve created an extra step in a system that is not correctly set up and are now forced to do something simple in a convoluted way.
My suggestion is to redo it before it’s too late.
And no, no indexing is needed. It’s an event based OOP approach. You may need indexes for something else, ofc. Not this, though.
Oh ok so the payload is the widget i’m moving around which in my case is this Skill button UI widget. If i set it to hidden (set visibility) on the skill button/ on drag detected nothing happens. If i set visibility on drag detected/ action bar slot widget then this action bar slots dissapier when dragging from slot to the next one. I will experiment further with this. I was thinking on “Event drag leave” to set somehow the action bar slot widget to get back to the default settings like blank state.
I rather wish to erase the info that something was in there at all. So pressing a key will not execute the hidden skill if it is just hidden and i understand this correctly.
ok i got the payload as variable so i can get this from the operation and connect it to “Drag Drop” widget. But then i cannot connect it to Add Child node to “content”
The first one you cannot connect because you are attempting to treat your custom drag & drop op (that extra step that stems from using that tut) as a widget which it clearly is not.
The second one does not work because, again, the Operation is not a widget.