I’m mocking up some card game functionality and I wanted to use a target cursor for my cards. I’m seeing some weird behavior and I’m not sure how to track it down. I have copy-pasta’d the same code for 2 different drag from widgets. One at the top of the screen and the card itself. The same code, same widget has different behavior and I don’t know why. Here is a video that shows the issue:
I’m really confused on why it’s doing this. Here is the logic:
Can you show the designer hierarchy of the cursor widget?
So how do the cards work? Are they nested in something? Are they anchored to the bottom of the canvas perhaps?
Judging by the behaviour in the vid, it seems that each card is sitting at the bottom of the canvas. and when drag creates the cursor, it’s using widget geometry - which I think is full screen atm. Do tell if I’m wrong.
I’m using some blueprints from this toolkit: CCG Toolkit in Blueprints - UE Marketplace for arranging the cards at the bottom. Though, I’m doing things a little different because they drag from screen space to world space and I only need the cards to exist in screen space. They are added to a canvas panel and then programmatically positioned along the bottom of the screen. The cursor I’m dragging from at the top of the screen is positioned in the designer, so maybe that’s the difference?
There are a lot of annoying issues I’ve run into with UMG drag and drop, so this is just one of many. Like not getting mouse updates once you’re dragging a widget. I’m attempting to use the drag operation to work around that because I need to project into world space when I target something.
Thanks for taking the time to help me think about this.
Oh, also I recorded that from the editor so it wasn’t fullscreen at that time.
I’ve seen the toolkit before, but I’m unfamiliar with its inner workings.
They are added to a canvas panel and
then programmatically positioned along
the bottom of the screen.
So it’s just create widget → add to canvas → as canvas slot → set position?
How about the card itself - how the hierarchy in there? I’m assuming here that you’ve got the Drag implemented in the card, right?
Like not getting mouse updates once
you’re dragging a widget.
You’re getting updates, just not from the Player Controller - you can get updates from the widget you’re dragging over or override DragDrop Operation’s Drag (you’d need to create a custom one) - the best way, works for both world & screen and allows you to pipe in any additional data you may need. Check my entry here.
Apart from that, UMG is full of quirks.
So that’s what the card looks like. The code that places them starts them offscreen, then has a gate in the tick that moves them to their goal location when it is opened. When they get to position, it’s closed. I’ve disconnected all of that and put them at their goal location to start and it does the same thing.
Yes, the drag implementation is inside the card widget. I may try all of this in a fresh project soon since it really doesn’t make much sense. I did notice that the ccg toolkit does custom drag/drop logic. I have to wonder iif they also ran into strange issues.
As for the dragging issue, yes I have seen that post and I have created my own drag operation and overridden the dragging method. Thanks
So it’s pretty much what I mentioned above:
Judging by the behaviour in the vid,
it seems that each card is sitting at
the bottom of the canvas.
Since drag is implemented in the CardWidget, I think its canvas is used as widget geometry during dragging. So what you’re really dragging is not the ViewCard, you’re dragging a full screen canvas that happens to have a ViewCard anchored - the cursor is created in the upper left and the drag operation sluggishly interpolates its location, as it always does. I’ve seen this behaviour manifest before but never to the extent you demonstrated here.
I don’t know if there’s a workaround in blueprints. I might be missing something obvious here, though. Do consider leaving this thread hanging, perhaps someone else can chip in.
One thing I’d definitely try is to implement the drag in the ViewCard directly, skipping this seemingly unnecessary hit box and the inner CanvasPanel; not sure why they chose to nest it in yet another element. All cards are added to the same canvas eventually anyway, right - so that opens up room for Z ordering and other canvas slot goodness.
I did notice that the ccg toolkit does
custom drag/drop logic. I have to
wonder iif they also ran into strange
UMG is by far the quirkiest part of UE4 as far as I am aware, not surprised.
If I had to guess I’d suggest looking for a spawn starting off-set of the target decal attached to the bottom D&D setup; but UI isn’t one of my strong points; just a place I’d start based on what your video shows.