1.5 KiB
1.5 KiB
OGG Shooting System - Setup Guide
Scene Hierarchy (how it should look)
Player [CharacterController + FirstPersonController + SimpleCrosshair]
└── Camera [Camera + AudioListener + CameraShake + WeaponBob]
└── Gun [SimpleGun]
Step-by-step Setup
1. Player object (already done)
- Has: CharacterController, FirstPersonController, SimpleCrosshair ✔
- Fix: Drag the Camera child into the
Player Camerafield on FirstPersonController
2. Camera object (child of Player)
- Has: Camera, AudioListener ✔
- Add Component:
CameraShake - Add Component:
WeaponBob
3. Gun object (child of Camera)
- Currently empty!
- Add Component:
SimpleGun - The gun auto-creates its own primitive model and muzzle flash
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!
Controls
| Key | Action |
|---|---|
| Left Click (hold) | Shoot (automatic fire) |
| R | Reload |
| W/A/S/D | Move |
| Shift | Sprint |
| Space | Jump |
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.bobFrequencyand amplitude values - Recoil punch:
SimpleGun.recoilKickbackandrecoilKickUp