I’ve been trying for a while to mimic the dragging system that Clash of Clans has when building your base, or that Clash Royale has when playing the game, where you have a row of cards that you can drag into the game, and the cards transform into units/buildings that you can place as you drag them. But I just haven’t been able to get anything working.
I have a widget called UnplacedUnit that acts like a card with one big button overlaying it, and it’s a part of a scroll box so that contains all of the player’s cards. I tried implementing a drag system with the built-in drag/drop operation, and I can move the card around, but I have no way of tracking the player’s mouse to move the unit after I create it since the mouse position isn’t updated while dragging. There are some other problems too that prevented the built-in drag/drop system from working (since the system isn’t designed for what I’m trying to do).
I also tried using a more brute-force approach of activating a tick function that constantly updates the card and piece’s positions when it detects the card being pressed, but I couldn’t make this work either because I couldn’t align the dragged cards with the mouse, not to mention that it’s very slow and the dragging is delayed.
I decided to remove all of the dragging classes and code from everywhere and to start again from scratch, but I’m kind of out of ideas. What would be the best way to implement this system?
Thanks in advance!