![3d maze man 3d maze man](https://sourceforge.net/p/dxwnd/discussion/general/thread/bfdb3af49e/01a7/attachment/3dmazeman.jpg)
This is due to the Maze Colliders are not perfectly aligned. Note: Later on, you may experience Pac-Man getting stuck in the maze or have trouble moving. The trick is to choose the Collider's Center and Size properties so that they are always like 1.25 or 1.5 or 1.75 or 2.00, and never like 1.24687 or 1.25788. For example if we zoom in then the green line should still perfectly wrap around the blue box: It is very important that each Collider is aligned perfectly. All we have to do is select Add Component -> Physics 2D -> Box Collider 2D, press the Edit Collider button and then modify it in the Scene until it fits the next wall. We will repeat this process for every wall in our maze. This allows us to modify the Collider in the Scene by using the green dots: Let's click on the Edit Collider button in the Inspector: We could either create an algorithm that reads the maze image and generates Colliders based on it, or we could just keep it simple and add all the Colliders manually. What we really want is to have a Collider around each wall of the maze. If we take a look in the Scene then we can see that Unity wrapped the Collider around the whole maze, which is not exactly what we want: We will select Add Component -> Physics 2D -> Box Collider 2D in the Let's change that by adding a Collider for each wall in the maze. It's not part of the physics world, things won't collide with it and Pac-Man could walk right through the walls. Right now the maze is only an image, nothing more. Z axis can be used to move elements away/towards the camera for added 3D effects, but in our Pac-Man project, we need to ensure that it's kept set as 0. Note: We make sure Z is set to 0 as we are working in a 2D environment. Let's take a look at the Inspector and position the maze at (X 0, Y 0, Z 0) in order to keep things clean: Now we can drag the Maze Sprite from our Project Area into the Scene: We selected Bottom-Left for the Pivot because it makes the alignment easier later on. We selected the value 8 because the distance between two Pac-Dots (the food) is always 8 px and we want that distance to be 1 Unit in our game. We will use this value for all our textures. Note: a Pixels Per Unit value of 8 means that 8 x 8 pixels will fit into one unit in the game world. We need to modify the Import Settings in the Inspector as shown: Note: right click on the image, select Save As., navigate to the project's Assets folder and save it in a new Sprites folder.Īfter saving it in our Project directory we can select it in the Project Area:
![3d maze man 3d maze man](https://productimages.worldofbooks.com/B001FBRAII.jpg)
We will draw one that is inspired by the original one, but not completely the same: We will also adjust the Size and the Position like shown in the following image: Creating The Maze The Maze Sprite Once Unity has created our project and loaded the editor which may take a few minutes depending on your computers' hardware, select the Main Camera in the Hierarchy and then set the Background Color to Black. We will name it PacMan, save it in a location such as C:\GameDev, select the 2D Game template and click Create Project, as shown below: We will start the Unity Hub and select New Project: Please adapt the instructions to your version accordingly - most of the time, newer versions of Unity have User Interface differences that can throw people off-guard. Unity 2018.3 and newer versions should work fine as well, older versions of Unity may or may not work. Our Pac-Man Tutorial will be developed with Unity 2018.4 (also known as 2018 LTS). By completing those tutorials before attempting this one, you will feel at ease with this tutorial.
![3d maze man 3d maze man](https://thumbs.dreamstime.com/z/standing-front-d-maze-huge-concrete-43122664.jpg)
3d maze man free#
And if you didn't or you don’t fully understand the basics, don't worry about it too much as we’ve got you covered.įeel free to read our easier Unity Tutorials like the Unity 2D Pong Game to get a feeling for the engine first. If you know your way around Unity and heard about GameObjects, Prefabs and Transforms before, then you are good to go. This tutorial does not require any special skills. Here is a preview of the final game in action:
![3d maze man 3d maze man](https://thumbs.dreamstime.com/z/3d-man-maze-25761521.jpg)
We'll focus on the Maze, the Ghosts, the food ( pellets) and of course, the hero himself: Pac-Man.Īs with our other tutorials, we'll keep things as simple as possible so everyone can understand it.
3d maze man code#
The game took the world by storm and due to its popularity, Unity Technologies included a tiny easter-egg featuring Pac-Man in their game engine:īy the end of this tutorial, we have a fully functional Pac-Man clone with only 62 lines of code by utilizing Unity's powerful 2D features. The original game was released in October 1980 and soon became the most famous arcade game of all time. Let's make a Pac-Man inspired game in Unity.