Skip to content
Adam Graham edited this page Feb 12, 2022 · 18 revisions

Links

FAQs


The ghosts are running into the wall instead of turning

If the ghosts are not turning, this implies a problem with the node system since the ghosts only change direction when touching a node. First, make sure you don't have any missing nodes on any of the corners. Double check your Node prefab has a collider component with the Is Trigger property checked on.

One of the easiest ways to cause this problem is by turning off the "Nodes" game object entirely instead of disabling only the Tilemap Renderer component. The tilemap is only used as a visual debugging aid for the nodes, so we disable it for the actual game. However, if you disable the entire game object, this also disables the Node scripts from running which is needed for the ghosts to move properly.


The pellets are not disappearing when eaten

This problem is usually caused if you have assigned a sprite to the pellet tile asset(s). We assign the sprite to the SpriteRenderer component on the pellet prefabs but not to the pellet tiles themselves. The prefabs are assigned to the tiles, and a copy of that object is spawned for each pellet tile on the map. Once these objects are spawned, they handle rendering the pellet and our scripts will disable the object once eaten. The script is unable to update the tilemap so if we assign a sprite to the tile asset, then it will show up permanently on the board.


How do I add scoring and lives?

I did not cover this in my tutorial video because the video was already so long, but I did include the implementation for scoring and lives in the full project source code: https://github.com/zigurous/unity-pacman-tutorial. Most of the code for this is handled in the GameManager.cs script, if you want to take a look at how I handled it.


How do I install the '2D Tilemap Extras' package?

Documentation: https://docs.unity3d.com/Packages/[email protected]/manual/index.html

Editor method:

  1. Navigate to the menu Edit > Project Settings, then select the Package Manager settings.
  2. Check on the box called Enable Pre-release Packages.
  3. Navigate to the package manager from the menu Window > Package Manager.
  4. Change the dropdown to Packages: Unity Registry.
  5. Find the package called '2D Tilemap Extras' and click the Install button

Manual method:

  1. Open the file Packages/manifest.json in a text/code editor
  2. Add a new entry "com.unity.2d.tilemap.extras": "2.2.0", alongside the other packages
  3. The package should be automatically installed the next time you open the Unity editor
Clone this wiki locally