Back to Mirador Blog

Compass(es)

2025-07-01
3 min read
UI/UX
miradorgame-developmentrust

Large mazes create navigation challenges that can frustrate players. Without guidance, finding the exit becomes a matter of luck rather than skill. To address this, I implemented a compass system that points players toward the maze exit. Rather than creating 3D models, I chose to manipulate a 2D image to produce an array of compass sprites. This approach generates 26 unique orientations, enabling the compass to point in any direction across a full 360 degrees. ![An array of a simple compass sprite showing the various directions that the triangle in the center of the sprite can be oriented.](/assets/images/compass-collage.jpg "The 26 Unique Compass Sprites")

Initial Implementation Challenges

The first compass implementation faced unexpected behavior. When incorporating the player's yaw into the compass orientation, the needle spun wildly. After several hours of troubleshooting, I simplified the approach to use only the player's position and the exit's location, ignoring the player's viewing angle. This basic compass provided immediate navigation assistance while revealing an opportunity for progression mechanics. Once mouse input is properly implemented, I can create an upgraded compass that incorporates the player's viewing angle for more precise navigation.

Yaw Integration

Further experimentation revealed the solution to proper yaw tracking. The key was mirroring the trigonometric calculations used by the player movement system. The compass now correctly points relative to both the player's position and viewing angle using this approach: 1. Calculate the direction vector from player to exit 2. Get the forward vector based on the player's yaw (using sine and cosine) 3. Get the right vector perpendicular to the forward vector 4. Project the exit direction onto these vectors to get the relative angle The result is a compass that smoothly indicates the exit's position relative to the player's orientation, making navigation much more intuitive.

Two Compass Models

With yaw tracking working, solving mazes became significantly easier. Players no longer need to mentally translate between absolute directions and their current orientation. This led to implementing two distinct compass models:

  • Basic compass: Shows absolute direction regardless of player orientation
  • Gold compass: Incorporates the player's current viewing angle

![Side-by-side comparison of the regular compass (left) and gold compass (right)](/assets/images/compass-comparison.png "Regular vs Gold Compass")

Progression System

The compass differences provide a natural progression opportunity. I envision an achievement system where players unlock the gold compass after completing a certain number of mazes or finding special pickups in challenging levels. The enhanced compass would become a permanent upgrade, providing tangible rewards for progression while maintaining the game's difficulty curve through other mechanics like maze complexity and time constraints. This provides a perfect opportunity for an in-game upgrade that can be earned as the player progresses. I envision an achievement system where players can unlock the gold compass after completing a certain number of mazes, or by finding a special pickup in a particularly challenging level. The enhanced compass would then become a permanent upgrade, providing a tangible reward for player progression while maintaining the game's increasing difficulty curve through other mechanics like maze complexity and time constraints.