This should be a common straight forward thing to do in UE.
How do I select an onscreen Sprite and drag it to a new location.
I want to use Sprite Chess Pieces, and move them on a Chess board,
with the mouse. This type of thing should be very common in Games,
and yet I can’t find a tutorial on how to do this.
Hey @Abbarue!
Sprites aren’t really intended to be used for this purpose. Have you thought about making it entirely UI?
Yes I followed a tutorial HTF drag and drop, but can’t seem to get it to work with the chess board in the back ground. Do I use Image buttons or use individual widgets for each board square? The widget I put on top of the chess board, blocks the board squares from view, and when I try setting them invisible, the chess pieces are also invisible. This is really difficult to get solved. So I thought maybe use drag and drop sprites on a background board. If I use the widget method what kind of objects do I use in the individual board squares. Most tutorials are on inventory widgets, and they just use MT squares for the inventory slots, and don’t care about covering the background image up with the drag and drop image, because the inventory slots are just MT squares.
i wouldnt use widgets, if youre using sprites you probably have a fixed camera anyway so you can put a texture on a plane/cube object that faces the camera and move the object.
the reason is you may want collision etc, ie is there a piece already there.
in short to do this,
just get a hit result under curser on click, if valid snap the object to the cursor position and on release set the object position in world
I have a nice working 3D chess board, but now I want to make a simple 2D chess board like you see on Chess.com. Most people like playing on that type of chess board. Maybe one of you people out there that like making Tutorials could make one on this. Perhaps also add some way of lighting up the UI squares to indicate which squares you can move to. I tried just turning my 3D chess pieces on their side and placing them over the 3D board squares, but it just doesn’t work as smoothly as those 2D boards you see in every free chess program out their.
just keep it 3d and make a fixed overhead camera so it looks 2d
How do you attach a 3D object to the mouse arrow and drag and drop it to a new square. Does the Drag & Drop actor work with 3D objects too?
na you create your own as i explained above.
While on the topic of Chess. Does anyone know how to convert the MiniMax algorithm into blueprint form. There are lots of examples of the algorithm, even ChatGPT gave me a detailed example of it. But I’m not sure how to convert that to Blueprints. Pseudocode:
function minimax(node, depth, alpha, beta, maximizingPlayer):
if depth is 0 or node is a terminal node:
return the heuristic value of the node
if maximizingPlayer:
bestValue = negative infinity
for each child in node's children:
value = minimax(child, depth - 1, alpha, beta, FALSE)
bestValue = max(bestValue, value)
alpha = max(alpha, bestValue)
if beta <= alpha:
break # Beta cut-off
return bestValue
else: # minimizing player
bestValue = positive infinity
for each child in node's children:
value = minimax(child, depth - 1, alpha, beta, TRUE)
bestValue = min(bestValue, value)
beta = min(beta, bestValue)
if beta <= alpha:
break # Alpha cut-off
return bestValue
# Initial call for a two-player game
bestMove = minimax(initialNode, depth, negative infinity, positive infinity, TRUE)
I’m thinking of using 2 arrays. #1 stores each move made, and #2 uses matching index of location for storing the value of each move. But I haven’t got it quite figured out yet. I have everything else in place, just need to figure out best move value. Also considered using one array of 10 digit int. And using lower 4 digits to store To & From locations and the higher 6 digits to store move value. The from will link this move to last move by From Location.
But if someone can convert that MiniMax algorithm into BluePrint I can go from there.
value = minimax(child, depth - 1, alpha, beta, FALSE)
bestValue = max(bestValue, value)
alpha = max(alpha, bestValue)
How would you convert that stuff in brackets into Blueprints? Looks like a multidim. array to me, but UE Blueprints doesn’t do Multidim. arrays.