x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Sliding Block Puzzle Blueprint

Could anyone help me as to be able to create a sliding puzzle with the use of blueprint. alt text

The furthest that I can understand is that I will need to line trace to be able to see if that individual piece has a free slot beside it to be able to move there. alt text

And then with booleans for when they are in the correct spaces.

Product Version: Not Selected
Tags:
more ▼

asked Feb 17 '15 at 03:08 PM in Blueprint Scripting

avatar image

greenday21
21 10 8 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first
more ▼

answered Apr 22 '15 at 01:11 AM

avatar image

Stache
61 5 6 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Edit 5/16/2018 - See my other answer. I've made available a fully functional demo of this in the first person template game type. Check my other answer below! **You can download the project files, add to your Unreal Projects Folder, and take a look at all the Blueprints/Actors in the Slider_Puzzle folder: https://drive.google.com/open?id=12LiYMdXEmnvlqSnnW9U8_wGnTwE5wvl3**

Many thanks to these two for providing the much needed legwork in how to accomplish this.

alt text

alt text

alt text

6zec6gw.png (294.3 kB)
rlxttly.png (226.1 kB)
3yue9u2.png (266.3 kB)
more ▼

answered Feb 22 '18 at 05:20 AM

avatar image

drowanpower
11 1 2

avatar image LeaCalderon Apr 27 '18 at 08:34 PM

I'm trying to make exactly what you made, do you have more pictures of your blueprint? I'm trying to make my first game and have no idea where to start with this.

avatar image drowanpower May 01 '18 at 02:59 PM

Sure, here is a link to a gallery of more screens:

edit: 5/15/2018 - Added additional pictures showing the variables and descriptions for each - thanks Awliee! https://imgur.com/gallery/bOtf8WZ

I am in the process of overhauling this entire Blueprint, and will update this answer with more information once complete!

The basic idea is this:

  1. You have an array of X number of 'Block' actors, in this case 9. I chose to set these up as child actor components within a parent actor, but there could be other ways to set them up.

  2. Each block has a location value, in this case we only care about the X and Z values of each block.

  3. Each block also keeps track of it's current index position and it's 'correct' index position. For example, block 6 has a current index position of 0 (top left), but it's correct position would be 5.

  4. One block has the boolean 'Is Missing Block' set to true. This blocks positioned is kept track of as well.

  5. Once you the player, select a direction to move, the parent actor checks each of it's child actors positions at an offset. For example, if you select 'UP', it will check the position of 1 block above each block in space.

  6. If that offset position is EQUAL to the position of the missing block, it will then swap the positions of the Missing Block and the Block to Move, using a temporary placeholder vector position variable to help the transition.

  7. After it swaps the 'Missing' and 'Moved' Block, it updates the index position on those blocks, and then checks the current Index positions on all blocks against their correct positions.

  8. If the number of correct positions is equal to the length of the block arrays, the puzzle is 'complete' and you can fire off whatever functionality you want off that.

I hope that helps in some way, I may make a tutorial for just the sliding block component when I have some more free time here. Let me know if you have any specific questions or issues!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I wanted to update this thread again for anyone who finds it or is having trouble completing their own slide puzzle. I've lifted the Slide Puzzle setup I have in my game and ported it into an isolated project with some of the bells and whistles missing, but core functionality is there. This doesn't use any line tracing, instead it just compares vectors in relative space.

You can download the project files, add to your Unreal Projects Folder, and take a look at all the Blueprints/Actors in the Slider_Puzzle folder: https://drive.google.com/open?id=12LiYMdXEmnvlqSnnW9U8_wGnTwE5wvl3

Demo notes:

  • The blueprints are mostly commented as it goes through logic/functions. Some of the comments may have been lost in the porting process, so if anything is unclear leave a comment here!

  • In the demo map, you can see the Slider_Puzzle_AutoGenerate (the puzzle itself) and a Slide_Puzzle_Controller_New (the controller trigger). Note that on the Puzzle_Controller, it has a variable that has been set to reference the Slider_Puzzle in level. This is how the player controls communicate with the Slider Puzzle actor.

  • Select the Grid Size (2x2, 3x3, 4x4, 5x5) on the Slider Puzzle_Auto_Generate and it will spawn the blocks automatically. Be sure to also set the appropriate texture so the numbers match up properly on the tiles. You can add your own Textures/Photos and it will splice them up automatically. I included a sample texture photo of my hometown to demonstrate. :)

  • At game start, it will randomize the blocks and cut up the assigned texture. Refer to the Array of Structs 2x2UVData, 3x3UVData, etc. and the Puzzle Master Material for how this is achieved.

  • The randomized blocks are checked for parity (I found this here https://www.cs.bham.ac.uk/~mdr/teaching/modules04/java2/TilesSolvability.html by brilliant Mark Ryan). If an unsolveable puzzle is generated, it will re-randomized the blocks and check again. This is honestly the most important element of this whole thing, otherwise you can end up with broken puzzles. Look at the CheckInversions function in the Puzzle actor for this.

  • Since the blocks spawn from the bottom up, the solution is numbers go bottom to top, left to right (i.e 1 in the bottom left corner, missing block in the top right corner).

Give it a whirl and let me know what you think! It's not fancy but it's got all the basic logic involved in creating your own puzzles!

more ▼

answered May 16 '18 at 06:22 PM

avatar image

drowanpower
11 1 2

avatar image Awliee May 16 '18 at 07:04 PM

havent checked this, but i have used your previous imgur guide to set up my own sliding puzzle in VR (had to completely change the logic in the checkForMissing function and some other stuff) but the general layout helped me out so much.

Thanks for your work

avatar image drowanpower May 16 '18 at 07:22 PM

That's great! I'm gald I could help you out, I'd be very interested to see a VR execution of this! The new .RAR just has grid size selection, proper randomizing at runtime, and solution validity checks added.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question