Link : https://www.youtube.com/watch?v=KDW9y0abvKY&t=2s
A small-scale RTS (Real-Time Strategy) base-building and unit-control demo.
- โ Built in Unity 2021.3.45f1 LTS
- ๐ฏ Core features:
- Grid-based building placement with snapping
- Unit production & combat
- Responsive UI & info panels
- Object pooling
- LineRenderer-based drag selection
- ScriptableObject architecture
- Resolution-independent camera & UI
- Custom spawn point system with visual feedback
| Action | Input |
|---|---|
| Select a unit | Left-click on unit |
| Drag-select units | Hold left-click & drag |
| Move units | Right-click on ground |
| Attack target | Right-click on enemy/building |
| Set spawn point | Right-click with building selected |
| Destroy selection | Click trash icon in info panel |
- Place buildings (Barracks, Power Plants, etc.) on the grid.
- Select a barracks to spawn units using the buttons.
- Units can be commanded to move or attack using right-click.
- Each building has health, size, and production rules.
- Buildings show a flag (valid) or cross (invalid) spawn point.
- Units automatically pathfind and retry attacks if blocked.
- Object Pooling โ
ObjectPoolManager - Grid Occupancy โ
GridManager - A* Pathfinding โ
Pathfinder.cs - Event-based Input โ
ClickInputRouter - LineRenderer Selection โ
UnitSelectionHandler - Factory Pattern โ
UnitFactoryMB,BuildingFactoryMB - Data-Driven Setup โ ScriptableObjects for Units & Buildings
- Sprite Atlas โ Packed via Unityโs Atlas system
- Responsive Camera โ Dynamically resizes based on resolution & layout
- UI Panels โ TMP-based with dynamic info population
- Custom spawn point is placed using right-click on ground with a building selected.
- Selection line is shown using a
LineRenderer, not a UI element โ fully resolution-independent. - UI scales with
CanvasScalerand adapts to both portrait and landscape. - Health bars and info panels are updated in real-time using
Events.