CozyCityBuilderPrototype: A Unity Isometric City Builder

April 2, 2025

Project Overview

Today I want to share details about my Unity-based isometric city building game prototype. CozyCityBuilderPrototype is designed with relaxation in mind, allowing players to create their own cozy little cities at their own pace.

I've always been fascinated by city builders and management games. There's something deeply satisfying about watching a city grow from nothing into a bustling metropolis. With this project, I wanted to focus on creating a calm, stress-free building experience rather than the more frantic resource management seen in some city builders.

Core Features

Technical Implementation

The project leverages Unity's built-in systems while adding custom functionality where needed. Here's a breakdown of the key technical aspects:

Code Structure

The codebase follows a modular approach, organized into several logical directories:

Design Patterns Used

The project implements several design patterns to ensure clean, maintainable code:

Challenges and Solutions

One of the most challenging aspects was implementing the isometric coordinate system. Converting between world, grid, and screen coordinates required careful math:

// Converting screen position to isometric grid position
public Vector2Int ScreenToGridPosition(Vector3 screenPosition) {
    Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPosition);
    // Convert world position to isometric grid position
    int x = Mathf.FloorToInt(worldPos.x / tileSize + worldPos.y / (tileSize/2));
    int y = Mathf.FloorToInt(worldPos.y / (tileSize/2) - worldPos.x / tileSize);
    return new Vector2Int(x, y);
}

Another challenge was optimizing the rendering for large maps. I implemented a chunking system that only renders tiles visible to the camera, significantly improving performance on larger maps.

Player Controls

The control scheme is designed to be intuitive and user-friendly:

Save System

The save system uses JSON serialization to store all relevant game data:

// Save data structure
[Serializable]
public class SaveData {
    public int mapWidth;
    public int mapHeight;
    public List tiles = new List();
    
    [Serializable]
    public class SerializedTile {
        public int x;
        public int y;
        public int type;
        public int buildingId;
    }
}

Future Development

While this is currently a prototype, I have several features planned for future development:

Conclusion

This prototype serves as a solid foundation for building a complete city builder game. The focus on creating a relaxing experience has guided many design decisions, from the calming visual style to the intuitive controls.

If you're interested in game development, city building games, or Unity development, feel free to check out the project on GitHub. I welcome any feedback or contributions!

View Project on GitHub