added gun models and enemy spawner

This commit is contained in:
2026-02-11 16:21:45 +00:00
parent 2d70da4827
commit 50968843e5
16 changed files with 1372 additions and 189 deletions

View File

@@ -1,105 +1,46 @@
# LiDAR FPS Game - Setup Guide
# OGG Shooting System - Setup Guide
## Project Structure Created:
- **Assets/Scripts/** - Your C# scripts (including FirstPersonController.cs)
- **Assets/Models/LidarScans/** - Where you'll import your GLB files
- **Assets/Prefabs/** - For reusable game objects
- **Assets/Scenes/** - Your game levels
## Scene Hierarchy (how it should look)
## Step 1: Import Your GLB Files
```
Player [CharacterController + FirstPersonController + SimpleCrosshair]
└── Camera [Camera + AudioListener + CameraShake + WeaponBob]
└── Gun [SimpleGun]
```
1. Open Unity and your OGG project
2. Copy some GLB files from `K:\OGG\lidar\` to `K:\OGG\OGG\Assets\Models\LidarScans\`
- Start with one or two to test (e.g., "my bedroom.glb" or "studio old.glb")
3. Unity will automatically import them
## Step-by-step Setup
## Step 2: Install glTFast Package (for better GLB support)
### 1. Player object (already done)
- Has: CharacterController, FirstPersonController, SimpleCrosshair ✔
- **Fix**: Drag the **Camera** child into the `Player Camera` field on FirstPersonController
1. In Unity, go to **Window → Package Manager**
2. Click the **"+"** button in top-left
3. Select **"Add package by name"**
4. Enter: `com.atteneder.gltfast`
5. Click **Add**
### 2. Camera object (child of Player)
- Has: Camera, AudioListener ✔
- **Add Component**: `CameraShake`
- **Add Component**: `WeaponBob`
## Step 3: Create Your Player
### 3. Gun object (child of Camera)
- Currently empty!
- **Add Component**: `SimpleGun`
- The gun auto-creates its own primitive model and muzzle flash
1. In the Hierarchy, **Right-click → Create Empty**
2. Rename it to "Player"
3. With Player selected, click **Add Component**
4. Search for and add: **Character Controller**
5. Add Component again, search for: **First Person Controller** (our script)
### 4. Testing enemies
- Create any GameObject (e.g. a Cube) in the scene
- Add a **Collider** (Box Collider, etc.)
- **Add Component**: `EnemyHealth`
- Shoot it and watch it flash red and pop!
## Step 4: Set Up the Camera
## Controls
| Key | Action |
|-----|--------|
| Left Click (hold) | Shoot (automatic fire) |
| R | Reload |
| W/A/S/D | Move |
| Shift | Sprint |
| Space | Jump |
1. In Hierarchy, **Right-click on Player → Camera**
2. Position the camera:
- Set Position Y to about 1.6 (eye height)
- Reset X and Z to 0
3. The FirstPersonController script should automatically find this camera
## Step 5: Import a LiDAR Scan into Your Scene
1. From Project window, navigate to **Assets/Models/LidarScans/**
2. Drag one of your GLB files into the Scene (Hierarchy)
3. Select the imported model in Hierarchy
4. In Inspector, click **Add Component → Mesh Collider**
- This allows the player to walk on it
5. You might need to adjust the scale:
- Try Scale: X=1, Y=1, Z=1 first
- If too big/small, adjust all values equally
## Step 6: Position Your Player
1. Select the Player in Hierarchy
2. In the Inspector, set Transform Position:
- Move the player above your scan (Y=2 or Y=3)
- Adjust X and Z to be inside the scan area
3. Make sure Character Controller settings are reasonable:
- Radius: 0.5
- Height: 2
- Center: Y=1
## Step 7: Test Your Game!
1. Click the **Play** button at the top
2. **Controls:**
- **WASD** or **Arrow Keys** - Move
- **Mouse** - Look around
- **Left Shift** - Run
- **Space** - Jump
- **Escape** - Unlock cursor
## Troubleshooting:
### Player falls through the floor:
- Make sure your LiDAR model has a **Mesh Collider** component
- Check that the Mesh Collider is enabled (checkbox ticked)
### Can't see anything:
- The camera might be inside geometry - move the Player position up (increase Y value)
- Check that the Camera is a child of Player and positioned at Y=1.6
### Movement feels weird:
- Adjust the Character Controller's Radius and Height
- Try different Walk/Run speeds in the FirstPersonController settings
### GLB files won't import:
- Install the glTFast package (see Step 2)
- Alternatively, you can convert GLB to OBJ using Blender if needed
## Next Steps:
Once you have basic movement working, we can add:
- Crosshair UI
- Health system
- Shooting mechanics
- Enemies/targets
- Multiple level loading
- Lighting improvements for your LiDAR scans
## Tips for LiDAR Scans:
- Your scans might be very detailed - this can slow down the game
- You may need to optimize them later (reduce polygon count)
- Start with smaller scans (single rooms) before loading larger areas
- You can have multiple scans in one scene to create larger levels
## Tuning Tips
- **Fire rate**: `SimpleGun.fireRate` (8 = fast, 2 = slow)
- **Shake intensity**: `CameraShake.Shake()` is called with (duration, intensity) - tweak in SimpleGun
- **Bob feel**: Adjust `WeaponBob.bobFrequency` and amplitude values
- **Recoil punch**: `SimpleGun.recoilKickback` and `recoilKickUp`