

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: 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.
#Pacman game 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: 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.
#Pacman game 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.
#Pacman game series
With the release of Pac-Man 99, fans looking to try some other games from the series may want to see where they rank among the rest according to critics and gamers everywhere.Let's make a Pac-Man inspired game in Unity. Suffice to say the Pac-Man franchise has had a few highs and lows. RELATED: Pac-Man: 10 Things You Never Knew About The Classic Video Game In fact, Pac-Man was partially responsible for the gaming industry's crash in 1983, thanks to the awful, yet high selling, Atari 2600 port of the arcade game, which is still considered one of the worst games of all time. Unfortunately for the circular hero, he hasn't reached anywhere near the same success on home consoles as he did on arcades. The original game's main strength was that it perfected the arcade formula of making a game simple yet addictive and punishing, encouraging players to keep putting coins in as they're convinced they can top their high score with their next try. Once the gaming industry's most recognizable mascot character, Pac-Manwas a dominant force in the arcades during their golden age.
