Back2Town

View on GitHub

Overview

Back2Town is an immersive 3D simulation created in Unity using C#, where autonomous agents navigate a town dynamically using Dijkstra’s algorithm. The project supports real-time scene editing, weather effects, camera control, and showcases smooth NPC motion with crowd-based pathfinding.

Key Features

🧭 Intelligent Pathfinding

Agents randomly select destination buildings and use Dijkstra’s algorithm to navigate efficiently through the town.

🧱 Interactive Scene Setup

  • Users can freely add obstacles to the environment.
  • Obstacle placement includes real-time distance control via mouse scroll.
  • Pressing "P" initiates the simulation once setup is complete.

🕹️ Real-Time User Interaction

During gameplay:

  • Use the mouse to highlight movable (blue) vs non-movable (red) objects.
  • Press space-bar while dragging to move selected objects dynamically.

🚶 NPC Movement & Crowd Simulation

  • Smooth multi-agent navigation with collision-free movement.
  • Custom-designed NPC models.
  • Realistic orientation smoothing and turning behavior.

🧭 Dynamic Camera & View Modes

Switch between eagle view and ground view dynamically using V key.
Mouse controls allow full 3D panning for immersive inspection.

❄️ Weather Effects

Features a snow particle system where flakes fall and disappear on contact with terrain, simulating dynamic winter weather.

🤖 Custom Assets

Includes original 3D-modeled robots designed by the developer.

Robot 1 (Floating)

Robot 2
Robot 2

Challenges & Solutions

🚧 Collision Avoidance

Porting TTC (Time-to-Collision) logic from Java to C# introduced discrepancies in vector calculations. Debugging focused on fixing subtle position misalignments causing residual collisions.

🧱 Complex Geometry Colliders

Accurately mapping bounds for custom-shaped assets required manual tuning, especially for irregular building meshes.

Development Details

  • Platform: Unity
  • Programming Language: C#
  • Tools & Assets: Blender (custom models), Unity Particle System, Line Renderer
  • AI Logic: Dijkstra pathfinding, NPC random goal selection, dynamic obstacle detection

Credits

External Assets

Models

Textures

Libraries