- Home /
Problem is not reproducible or outdated
Jigsaw Puzzle...
Hey guys.
I have this assignment at school where i have to make a Jigsaw puzzle in unity and i dont know how... My teacher told me to use arrays and drag n drop but i dont know what that is. I had no luck finding any tutorials on both. Can you please help me ?
do you have any basic skills with Unity?
you'll need to learn how to do "2D" -like effects in Unity. perhaps start with the "GUI" system. Good luck.
http://docs.unity3d.com/Documentation/Components/GUIScriptingGuide.html
Unity is 3d so it's not really designed for jigsaw puzzles. But like the other guy said, you just need to start learning GUI's and 2D textures.
Answer by PulseLight · Oct 12, 2012 at 04:59 PM
You can use 2D arrays to program the puzzle pieces:
var multiDimensionalArray = [
[1,2,3,4],
[5,6,7,8],
[9,10,11,12],
[13,14,15,16]
];
Each number representing a puzzle piece, when placed in order (like above) the puzzle is complete,you can verify that with:
var correctPieces: int = 0;
var currentPos: int = 0;
for (var i : float=0; i < multiDimensionalArray[0].Length; i++) {
for (var j : float=0; j < multiDimensionalArray.Length; j++) {
currentPos++;
if (multiDimensionalArray[i][j]==currentPos)
correctPieces++;
}
}
In this case you need 16 correct pieces, so when correctPieces==16 you win !
And you can scramble the puzzle randomly, manually or with code.
Follow this Question
Related Questions
Pulling Puzzler 2 Answers
How to select different objects with raycast (puzzle game) 1 Answer
How to use sections of a texture? 1 Answer
Any idea on how to make objects be clicked in a certain order? (C#) 1 Answer
How do I pick up an object and place it in a spot that kind of like a missing puzzle piece? 0 Answers