Hello all, I’m creating a top down card game and am trying to drop a card on to the battle field and spawn an actor at the drop location. I’ve created a widget for the card space and added a separate widget for the battle field.
In my widget designer, I have a widget for the battle field, Level, located on top of my In-Game widget so that the battle field knows where the card was dropped.
You can see in my Level widget graph, when a card is dropped onto it, it prints the position of the mouse and then is supposed to spawn an actor, Common, at the same location. The problem I’m having is the actor is clearly not being spawned at the mouse position.
No matter where I drop a card on the field, the actor is spawned in the same location at the top right of the screen.
Is there an offset, or another pin I should spawn from instead of GetScreenSpacePosition?
Line Trace from mouse screen position to world using “convert mouse location to world space” as source and direction.
Use build in “get hit under mouse cursor” , idea is the same, it’s line trace.
Use DragDropOperation / Widget data of drop and GetScreenSpacePosition → “deproject screen to world” and then find camera look at vector and linetrace from deproject location towards this dirrection to find your level drop location.
Here rough implementation. Check DragDropOperator for code. Google Drive: Sign-in
if you satisfy by result, make screenshots, update your question with result and mark question answered, its seems to be fairly frequently asked question.
Thanks, I see that you’ve basically got what I was looking for. I’m going to continue looking at your blueprints and try to modify mine in a similar way.
You’ve created a bit more things than I thought was necessary for my project, like the custom Drag and Drop Operation, but I think you’ve given me enough information.
I’ll update my answer when I get the correct results on my project.
A question I would have for you, with regards to your BPW_Test_Panel, is how your Create BP Drag Test pin has an extra input for Drag Actor. I’ve tried quite a few things to get this appear in my widget graph, but have yet to find a way.