I’m about to develop a simple VR jigsaw puzzle and I’m wondering what would be a good approach to this in unreal 4.27.
My thoughts are that I could create a framed area for the extent of the finished assembled puzzle, then create a matrix of sockets within this frame, which refers to the male and female parts of the puzzle pieces. Then create some simple logic to check if the piece of the puzzle is overlapping the correct socket. Would this approach work?
What would be another or better way of approaching this task?
Do not check if they are overlapping or not.
Such puzzle is done on tiled like surface (ie all tiles are boxes with fancy edges).
So instead give every tile x,y coordinate, and allow it to be placed only when its in corner, or has adjacent tile placed.
Actual shapes of tile really do not matter, only their index on grid.
Then calculate coordinates based on x,y and just attach (or spawn component) at correct location relative to parent.
I know placing random pieces until they do stick would remove big part of joy with such puzzle, so you need to limit such cheating.
My go to for this would be doubled up piece checking.
If it’s drag and drop - which let’s be real, it’s the only decent way to make puzzle tiles end up in the correct place - then the solution is as simple as having an invisible puzzle solution on the table, properly solved.
The mouse pointer (or center of used tile) runs a trace and checks for the piece name or a gameplay tag.
If that matches the piece you are dragging, it “does things”.
Does things,
Because placing in the tile at the right spot for the user is a bad idea.
But you can keep count of if it was in the “right spot” and maybe force align it and any other pieces marked as “right” once the 3 adjacent ones are placed.
Always, force align edge pieces. And probably always snap correct pieces to the edge piece.
All in all, it’s a cheap trick solution that just works, when you have a set solution…