# Super Dino Smash 🦖
A 3D dinosaur battle game built with Unity! Play as a T-Rex exploring a prehistoric world, battling other dinosaurs in an open arena.
## Quick Start
### Option 1: Auto-Setup (Recommended)
1. In Unity, create an empty GameObject called **GameManager**
2. Drag `Scripts/Managers/GameSetup.cs` onto it
3. Press **Play** - it will auto-configure everything!
### Option 2: Manual Setup
#### 1. Create the Player (T-Rex)
- Create a Capsule GameObject named **T-Rex**
- Set tag to **Player**
- Add these components:
- `CharacterController` (height: 3, radius: 0.8)
- `TrexController` (movement + camera)
- `CombatSystem` (health + bite attack)
#### 2. Set Up the World
- Add a **Terrain** (`GameObject > 3D Object > Terrain`)
- Create a **Directional Light** for the sun
- Set fog and ambient lighting in `Edit > Render Settings`
#### 3. Add Enemy Dinosaurs
- Create a prefab with:
- `NavMeshAgent` (for pathfinding)
- `AIController` (patrol/chase/attack AI)
- `CombatSystem` (health)
- Add `DinoSpawnManager` to manage spawning
#### 4. Add UI
- Create a **Canvas** with a health bar
- Attach `HealthBarController` to update it
## Controls
| Input | Action |
|-------|--------|
| **WASD** | Move |
| **Mouse** | Look around |
| **Left Shift** | Sprint |
| **Space** | Jump |
| **Left Click** | Bite Attack |
| **Right Click + Drag** | Camera rotate |
| **Esc** | Unlock cursor |
## Project Structure
```
Assets/
├── Scripts/
│ ├── Player/
│ │ └── TrexController.cs # Movement + camera
│ ├── Combat/
│ │ └── CombatSystem.cs # Health + attacks
│ ├── AI/
│ │ └── AIController.cs # Dino AI behavior
│ ├── UI/
│ │ └── HealthBarController.cs # Health bar UI
│ ├── World/
│ │ └── TerrainGenerator.cs # Terrain creation
│ └── Managers/
│ ├── DinoSpawnManager.cs # Spawns enemies
│ └── GameSetup.cs # Auto-configuration
├── Prefabs/ # Save reusable objects here
├── Models/ # 3D models
├── Materials/ # Materials/shaders
└── Scenes/ # Your game scenes
```
## Core Systems
### T-Rex Controller
- Third-person camera with smooth follow
- Walk/run with camera-relative movement
- Jumping with ground detection
- Animation state management
### Combat System
- Bite attack with range and angle
- Health with regeneration
- Knockback on hit
- Death animation + cleanup
### AI Controller
- State machine: Idle → Patrol → Chase → Attack → Flee
- Detection range with line-of-sight
- Patrol waypoints with random variation
- Flee when health is low
### Dino Spawn Manager
- Maintains target population
- Respawn dead dinosaurs
- Random or fixed spawn points
- Avoids spawning on player
## WebGL Build
To export for web:
1. `File > Build Settings`
2. Select **WebGL** platform
3. Click **Switch Platform**
4. Click **Build** and choose output folder
5. Unity will generate HTML + WASM files
### WebGL Performance Tips
- Use **Low** or **Medium** API compatibility level
- Bake lighting instead of real-time
- Use LOD (Level of Detail) for distant objects
- Compress textures
- Target 1280x720 resolution
- Keep polygon count under 50k per scene
## Next Steps
1. ✅ Basic movement and combat
2. 🔄 Add dinosaur 3D models (Mixamo or Unity Asset Store)
3. 🔄 Create multiple dinosaur types (Raptors, Triceratops, etc.)
4. 🔄 Add sound effects (roars, bites, footsteps)
5. 🔄 Build the terrain with trees, rocks, water
6. 🔄 Add a mini-map
7. 🔄 Create a start screen and pause menu
8. 🔄 Add XP/leveling system
9. 🔄 WebGL optimization and testing
## Free Assets to Get
- **Dinosaurs**: https://assetstore.unity.com/packages/3d/characters/animals/dinosaur-packs-24753
- **Nature Kit**: Unity Asset Store (free terrain assets)
- **Mixamo**: https://mixamo.com (free animated models)
- **Sound effects**: https://freesound.org
## Troubleshooting
**T-Rex falls through ground**
- Check that your Terrain has a Collider
- Make sure `CharacterController` is set up correctly
**Camera doesn't follow**
- Assign the Main Camera in `TrexController > Main Camera` field
**AI doesn't move**
- Bake NavMesh: `Window > AI > Navigation`
- Mark ground as walkable
**Health bar doesn't update**
- Make sure `HealthBarController` is in the scene
- Check that combat system references the health bar
## Controls Reference (In-Game UI Idea)
Create a UI Text component showing:
```
🦖 Controls:
WASD - Move | Mouse - Look
Click - Bite | Space - Jump
Shift - Sprint | Esc - Menu
```
## Credits
Built with Unity 2022 LTS
Engine: Unity
Language: C#
Target: WebGL / Standalone
## License
Personal learning project - modify freely!