# How can i do a Sliding Puzzle?

**URL:** <https://forums.unrealengine.com/t/how-can-i-do-a-sliding-puzzle/447879>\
**Category:** Community & Industry Discussion\
**Tags:** sliding, unreal-engine, puzzle, UE4, question\
**Created:** [April 25, 2019, 11:21pm UTC](https://forums.unrealengine.com/t/how-can-i-do-a-sliding-puzzle/447879 "2019-04-25T23:21:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolf\_Designer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wolf\_Designer](https://forums.unrealengine.com/u/Wolf_Designer)\
**Post date:** [April 25, 2019, 11:21pm UTC](https://forums.unrealengine.com/t/how-can-i-do-a-sliding-puzzle/447879/1 "2019-04-25T23:21:17Z")

</div>

Hi, i know how make a jigsaw but i need make a Sliding Puzzle on Blueprints, like this [Puzzle Unreal Engine 4 (01) beta - YouTube](https://youtu.be/aXtbiiCTOK4)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [April 26, 2019, 6:59am UTC](https://forums.unrealengine.com/t/how-can-i-do-a-sliding-puzzle/447879/2 "2019-04-26T06:59:12Z")

</div>

Are you asking about how to make an entire game or…? There are a lot of elements that have gone into this. Perhaps you could break it up into more digestible pieces, especially if you’re new to all this. Here’s a start:

Dividing a single image into interactive actors, I made this on a whim so it’s rather bare bones:  
[https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1411963-can-blueprints-be-used-to-chop-an-image-into-pieces?p=1412068#post1412068](https://forums.unrealengine.com/development-discussion/blueprint-visual-scripting/1411963-can-blueprints-be-used-to-chop-an-image-into-pieces?p=1412068#post1412068)

Depending on how complex and scalable the end result needs to be, there would be more or less elements that need to go into this, for the maximum simplicity I’d try:

- assign the pieces initial correct coordinates during the creation loop; so each piece knows that is has reached the correct spot once the puzzle is ready to be solved. The 2D macro will spit them out for you, just have the actors store them.
- for movement, I’d probably just do a _short_ line trace to see if there’s empty space a piece can move to - so 4 traces North, South, East & West in a Break loop until an empty space is found (the whole thing can be calculated manually, of course, since you have the coords, but the traces will be easier to set up). For simplicity sake you can put a border around the pieces to skip checks around the edges and prevent pieces moving beyond them.
- use _Snap Vector to Grid_ to find a resting position (or calculate manually again - you know the board size, piece size and the gap between the 2) and a _Timeline_ to move them; check here if the coords are matching - you will need to do it for all pieces

That _should_ work. There will be some _gotchyas_ here, surely.

---

<div class="post-metadata">

**Author:** ![Wolf\_Designer](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wolf\_Designer](https://forums.unrealengine.com/u/Wolf_Designer)\
**Post date:** [April 27, 2019, 6:20pm UTC](https://forums.unrealengine.com/t/how-can-i-do-a-sliding-puzzle/447879/3 "2019-04-27T18:20:36Z")

</div>

I understood it very well, right now I will be testing it, YOU ARE THE BEST!!!  
I THANK YOU A LOT, and I’m sorry about my English.
