Download

can blueprints be used to chop an image into pieces?

hi, i would like to create a simple jigsaw puzzle game to play around with. what i would like to ask if it is possible to let unreal engine cut the images up into pieces, without having to manually do it in another program because i would like to add settings for the number of pieces (3x3 ,4x4…ect)
thanks!

See if you can adapt the following to your needs:

A material for the actors. It takes 3 scalar values - U, V and Size. UV is going to shift the coordinate and Size dictates the number of pieces.

A *PuzzlePiece *actor that has a simple cube (with Z scaled down to make it flat), a Dynamic Material Instance is going to be fed data when the actor is spawned - the U, V and Size are variables ExposedOnSpawn

The *LevelBlueprint *spawns PuzzlePieces. The 2D Grid Execution Macro does the heavy lifting of distributing them and feeding the abovementioned material coordinates. The actors representing the pieces of the puzzle are stored in an array - you’ll want to interact with them later on, surely.

The end result:

It clearly needs more work but should be a decent starting point.

By adjusting Size, you should be able to get as many pieces as you need, 7x7 in this instance. The flattened cubes are 100x100, the gaps can be adjusted in the *2dGridExecutionMacro *- SectorSize.