You will follow me thru these things:
- Generating Maze
- Edit and export to Unity
- Use Sprite Editor in Unity to apply Custom Physics Shape
- (Optional) Edit more Outline for more accuracy
- Put the sprite into the scene
- Add Component — Polygon Collider 2D
- Testing for finishing
Generating Maze
The maze can be imported or generated by the program, both online and offline. But, me will use amaze (offline program) to generate a simple maze. We can also use online generator at mazegenerator.net . The generated maze can be saved as .png or etc.
Edit and export to Unity
Once we get our favored maze. We will edit that maze a lil bit in the image editor.
Don’t forget…! Export that edited image file (maze) to your Unity project.
Use Sprite Editor in Unity to apply Custom Physics Shape
i) Open Unity
ii) Try locate our maze file in the Unity project.
iii) Click maze
iv) Then, click Sprite Editor
v) Sprite Editor tab will popup!
vi) Choose Custom Physics Shape
vii) Set Outline Tolerance to 1 , and click Generate
viii) Click Apply
(Optional) Edit more Outline for more accuracy
You may skip this step if satisfied enough with the previous result..
Put the sprite into the scene
Just drag maze into the scene.
Add Component — Polygon Collider 2D
Polygon Collider 2D size = Outline (Custom Physics Shape) size
Testing for finishing
We can put the moving character in the scene, together with the completed maze.
Congrätz!! We have our playable Maze.
In a nutshell, we can create the maze collision with the easier way — Polygon Collider 2D. EXTRA: We can also create collision for the maze by using a lot of Box collider 2D. Hopefully, this tutorial could help your great works. Thank you so much for reading and me very appreciate your precious time. May God bless your works.