I recently rewatched the movie Pixels, with Adam Sandler and Peter Dinklage. Now the plot of this movie is fantastic, without spoilers, aliens come to Earth and attack the world using weaponry designed to be fought like playing old arcade games. Adam Sandler fights aliens in the form of Centipede, Pacman and then Donkey Kong. Now this movie could have inspired a multitude of VR games, but what I liked best was their version of Pacman. In the movie, the heroes are driving Mini Coopers dressed up to look like Blinky, Inky, Pinky and Clyde, while Pacman runs from them in the streets of New York.

Game Concept

For this game idea, I decided I wanted to be able to play as Pacman, in first person, exploring the maze and collecting Pellets while also avoiding ghosts. So the first thing I did, was I went to ChatGPT and had him reexplain to me the rules of Pacman, the point system, how the ghosts move, and how Pacman wins the game.

Modeling

The next thing I did, was I hopped into Fusion 360 and started working on some models. I took the ghosts from the Moped Mayhem project and redesigned them slightly. I then built Pacman as though he were a spaceship that I could pilot from the inside. I then brought them into Unity and gave them materials, making the Ghosts slightly transparent and glowing.

Pacmans Movement

It took me a while to decide how I should allow the player to move Pacman around the maze. At first I thought to design him like a car, giving the player a steering wheel and full control of Pacman’s movements. However I wanted to give the user a more retro feel, so I took a joystick from Valem’s Interactable testing scene and wrote a script to check if there was an obstacle in front of Pacman using a raycast, and if not then he could move forward. Then I added to the script to check for the value of the joystick to allow Pacman to turn left and right. Pacman has no reason to go up or down and he never needs to turn all the way around. I then added lights to the front of his head like headlights, and a text object to show the current score of the player. Finally I added what I think to be the coolest part of the project, the Display.

The Map

Deciding how to build the map was almost vital to this project. Now this was most accidental, but I built the map in Fusion 360 by simply drawing over an image of the original game map and only drawing the walls. I then extruded the walls as separate bodies, then I grabbed the sketch of the floor and extruded it as its own body. When I brought this model into Unity, I gave it materials and emissions. The 3D maze could now be explored by Pacman. The separate floor body became vital when working with The Ghosts.

The Ghosts

All four ghosts, Blinky, Pinky, Inky, and Clyde were very easy to set up. I simply brought the models in and gave them a collider, and a Nav Mesh Agent component as well as some custom scripts. Now this was my first time working with Nav Meshes and Unity’s AI system, but it went really smoothly and was incredibly quick to set up. First I grabbed the model of the maps floor and baked it as a walkable surface for the Ghosts. Thus, they already avoid all the walls in the map and can navigate toward a target. So I wrote a script to have them target the player and constantly move toward them. Unless they eat a power pellet of course, then I have them move in the negative direction of the player constantly running away. I then wrote the scripts to detect when the ghosts eat the player and what happens when the player eats a ghost during the power pellet timer.

The Display

I really wanted to have a mini map in this game. I’d never created one but I think I came up with a pretty neat idea for this one. Above the map sits a camera, this camera displays to a Render Texture. This allows me to put the output of the camera on a surface with a material. Then I created empty GameObjects parented to each of the moving objects in the scene. I then created Icons, small models representative of the moving character, that floated high above the actual object, just above the surface of the map ceiling. These Icons were visible to the camera but not to the player. So the player would have to look at the map to find the locations of the Ghosts, themselves, and the Pellets.

Pellets

So I realized the player had to earn points some how instead of just running from the ghosts the whole game. So I added the Pellets that Pacman needs to eat to earn points. In the game you just simply fly into the huge spheres and it collects 10 points for your score. Placing these pellets was easier than expected, I wrote a script that spawned them in a grid and then went through and manually removed the ones that didn’t fit or work properly. I then wrote the script for eating them, applying the points. Next I designed a Power Pellet, which was simply a larger pellet. This allowed me to put the 4 power pellets in the corners of the map. When eaten these activated the Eating Mode, which turns all the ghosts blue and makes them run from Pacman.

Final Touches

The game was done, all of the logic worked and the functionality was finalized. However I wanted to add some finishing touches to the style. I added some fog via post processing, and then sound effects that turned the game into a terrifying experience. The dark corridors loomed endlessly and the ghosts appeared as large glowing figures.

Playthrough:

Leave a Reply

Your email address will not be published. Required fields are marked *