168 lines of code generated.
Today I’ve been working on the shoot logic for the game, added an AI generated 3D pistol, and a simple UI.
The Player shooting script handles a pistol-style weapon. It manages firing, reloading, recoil, bullet holes, sound effects, and UI updates.
Key Features:
- Shooting Mechanic:
- Fires a raycast from the player’s camera.
- Reduces ammo with each shot.
- Plays a shooting sound.
- Applies random recoil spread to shots.
- Spawns bullet hole decals on surfaces.
- Deals damage to objects that implement the IDamageable interface.
- Ammo & Reloading System:
- Stores current ammo, magazine size, and reserve ammo.
- Pressing “R” (or when empty) triggers a reload coroutine.
- Plays a reload sound and refills the magazine from reserve ammo.
- Recoil System:
- Each shot increases recoil, affecting bullet spread.
- Recoil gradually decays over time.
- UI Updates:
- Updates ammo display using TextMesh Pro.
- Sound Effects:
- Uses an AudioSource to play shooting & reloading sounds.
